安装mysql
sudo pacman -S mysql
初始化语句
sudo mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql
设置开机自启
sudo systemctl enable mysqld.service
启动mysql服务
sudo systemctl start mysqld.service
查看mysql服务状态
systemctl status mysqld.service
输出如下
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2019-08-01 22:03:15 CST; 34s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 11218 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 11235 (mysqld)
Status: “SERVER_OPERATING”
Tasks: 38 (limit: 4915)
Memory: 373.0M
CGroup: /system.slice/mysqld.service
└―11235 /usr/bin/mysqld
其中里面自动生成了密码 一会儿用这个密码进去之后要记得修改密码
连接数据库
mysql -uroot -p
让输入密码
输入上面系统给生成出来的密码
修改密码
ALTER user ‘root’@‘localhost’ IDENTIFIED BY ‘新密码’;
感叹一下~linux安mysql比windows安这个容易的不止一点点呐 ~
参考文章
https://blog.csdn.net/AQ931752921/article/details/89308905
和
https://blog.csdn.net/weixin_43102407/article/details/98120156
来源:51CTO
作者:PERCENTILE__
链接:https://blog.csdn.net/PERCENTILE__/article/details/100834609