主机系统:ubuntu18.10
安装MySQL版本:MySQL-5.7.25
ubuntu查看系统版本: 命令: sudo lsb_release -a
ubuntu 18.1 安装 MySQL
目录
1.更新系统包索引 命令: sudo apt-get update
2.开始安装mysql 命令: sudo apt-get install mysql-server
4.查看MySQL的状态 命令 sudo service mysql status
6.重置MySQL密码 命令:(需进入MySQL)SET PASSWORD FOR root@'localhost' = PASSWORD('newpassword');
-
1.更新系统包索引 命令: sudo apt-get update
-
2.开始安装mysql 命令: sudo apt-get install mysql-server
注意: 上面命令执行后, 会出现存储空间使用允许的询问,输入 Y 就可以继续安装了。
#1
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N (我的选项)
#2
Please set the password for root here...
New password: (输入密码)
Re-enter new password: (重复输入)
#3
By default, a MySQL installation has an anonymous user,allowing anyone to log into MySQL without having to havea user account created for them...
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y (我的选项) # 若对mysql 不熟悉,建议选N(这样只要在命令行输入MySQL,就可以进入MySQL了。)
#4
Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess atthe root password from the network...
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N (我的选项) # 我需要远程使用root目录,建议选Y(基于安全)。
#5
By default, MySQL comes with a database named 'test' thatanyone can access...
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N (我的选项)
#6
Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (我的选项)
-
3.配置完成
-
4.查看MySQL的状态 命令 sudo service mysql status
active(running)就是正常运行的
-
5.登录MySQL 命令:mysql -u root -p
再输入密码就好了(输入密码屏幕是不会显示输入字符的)
-
6.重置MySQL密码 命令:(需进入MySQL)SET PASSWORD FOR root@'localhost' = PASSWORD('newpassword');