1, MySQL installation after the password can not be landed problem
Then you need to go into the/etc/mysql directory and check the username and password inside, and then
sudo vim debian.cnf
Use the username and password in this file to enter MySQL, if the username in debian.cnf is debian-sys-maint, then:
Mysql-u debian-sys-maint-p
Press ENTER, when you need to enter a password, copy the password in the DEBIAN.CNF (do not manually input, because error prone).
A prompt such as mysql> appears in the terminal:
Use MySQL
Show tables;//View the tables in the MySQL database and see a user table.
SELECT * from user;//to see if there is a root user in this table, if:
Update user Set Password=password ("root") whereuser= "root";//change the password for the root user to enter MySQL.
Flush privileges;
Quit quit MySQL.
and use
Mysql-u Root-proot
Re-login MySQL can be.
If there is no root user in the user table: with the grant command
Grant all privileges on *.* to root@localhost identified by ' 123 '
Where *.* represents all the tables in all databases, that is, the password that database name.your table ' 123 ' is represented as the root user.
Flush privileges;
SELECT * from user, and check to see if user has root in this table. If there are representations added successfully.
Quit quit MySQL.
Mysql-u root-p 123 into MySQL.
2. Configure Remote connection
①
vim/etc/mysql/my.cnf Find bind-address = 127.0.0.1
Comment out this line, such as: #bind-address = 127.0.0.1
or instead: Bind-address = 0.0.0.0
Allow arbitrary IP access;
Or specify an IP address yourself.
Restart Mysql:sudo/etc/init.d/mysql restart
Ii
Authorized users to connect remotely
Grant all privileges on *.* to root@ '% ' identified by ' password ' with GRANT option;
Flush privileges;
The first line of command is interpreted as follows, *.*: The first * represents the database name, and the second * represents the table name. This means that all the tables in the database are licensed to the user. Root: Grant root account. "%": Authorized User IP can be specified, where any IP address can access the MySQL database. "Password": Assign the password corresponding to the account, where the password is replaced by your MySQL root account password.