1, first log in as root user mysql
the root -p -u MySQL
2, the new user
MySQL use; SELECT Host, User from User; (See existing user) the CREATE the USER 'King' @ 'localhost' the IDENTIFIED BY '123456'; (new user);
SELECT Host, User from User; (see user again)
3, Fu rights
GRANT ALL PRIVILEGES ON *.* TO 'king'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
NOTE: king represents the user name,% means that all of the computers can be connected, may be provided connected to an ip address operation, the second code represents 123456,
4. Modify Profile
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
Note: some may be in /etc/mysql/my.cnf
5, restart mysql
MySQL restart Service
6, and some need to configure port
ufw 3306 the allow sudo
7. tested successfully
Reproduced indicate the source: https://www.cnblogs.com/jum-bolg/p/11291350.html