0.检查是否安装了MySQL数据库
sudo netstat -tap |grep mysql
如果没有提示,说明没有安装MySQL
1.在线安装MySQL数据库(安装了可跳过)
sudo apt-get install mysql-server
安装过程需要一次确认输入Y
这里如果没有让设置root用户密码,需要查看mysql生成的临时密码
cat /var/log/mysql/error.log
2019-06-13T09:30:45.674931Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-06-13T09:30:46.483069Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-06-13T09:30:46.639351Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-06-13T09:30:46.720793Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ec79226d-8dbd-11e9-89d4-ccaf78b0f058.
2019-06-13T09:30:46.731768Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-06-13T09:30:46.733850Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
........这里可以看出我的MySQL安装使用了空密码,有些版本的MySQL可能会生成一个临时密码,
可以在这个日志文件中找到
登录mysql
sudo mysql -u root -p //登录用默认密码
====分隔符===
mysql> set password for root@localhost = password('root');
Query OK, 0 rows affected, 2 warnings (0.04 sec)
//添加常用账户
// 本地账户alex,密码为123456
mysql> create user 'alex'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
//赋予权限
mysql> grant all privileges on *.* to 'alex'@'localhost';
Query OK, 0 rows affected (0.00 sec)
参考文章:
[ https://tydldd.iteye.com/blog/2047112 ]
网友评论