版本:Ubuntu_1804
、mysql_5.7
sudo apt-get update
sudo apt-get install mysql-server-5.7
-
vim /etc/mysql/mysql.conf.d/mysqld.cnf
注释掉bind-address
和skip-external-locking
并保存 - mysql默认username为root,密码为空,
可以执行sudo mysql_secure_installation
按照提示初始化密码。 -
sudo mysql -u root
进入mysql命令行后,新建一个mysql管理员账户。
参照:host-xxx-xx-xxx-xxx-is-not-allowed-to-connect-to-this-mysql-server
具体配置命令:
mysql> CREATE USER '${user_name}'@'localhost' IDENTIFIED BY '${some_pass}';
mysql> GRANT ALL PRIVILEGES ON *.* TO '${user_name}'@'localhost'
-> WITH GRANT OPTION;
mysql> CREATE USER '${monty}'@'%' IDENTIFIED BY '${some_pass}';
mysql> GRANT ALL PRIVILEGES ON *.* TO '${user_name}'@'%'
-> WITH GRANT OPTION;
- 使用mysql客户端,输入ip、端口、新建的mysql管理员账户、密码即可登录,大功告成。