安装并初始化MySql
sudo pacman -S mysql
正在安装 mysql-clients (8.0.11-1)...
正在安装 mysql (8.0.11-1)...
:: You need to initialize the MySQL data directory prior to starting
the service. This can be done with mysqld --initialize command, e.g.:
mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql
:: Additionally you should secure your MySQL installation using
mysql_secure_installation command after starting the mysqld service
初始化MySql数据目录/注意记录root临时密码
mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql
查看MySql状态
sudo systemctl status mysqld
启动MySql服务/开机自启
sudo systemctl enable mysqld
sudo systemctl start mysqld
账户安全设置/需要使用root临时密码登陆
mysql_secure_installation
使用workbench连接时需要修改密码规则
#出现
caching_sha2_password cannot be loaded
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #修改加密规则
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #更新一下用户的密码
FLUSH PRIVILEGES; #刷新权限
再重置下密码:alter user 'root'@'localhost' identified by '123qwe';
ERROR(重新安装后已解决)
Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
● mysqld.service - MySQL database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: activating (start-post) (Result: exit-code) since Sat 2018-05-26 19:41:34 CST; 18s ago
Process: 8359 ExecStart=/usr/bin/mysqld --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Main PID: 8359 (code=exited, status=1/FAILURE); Control PID: 8360 (mysqld-post)
Tasks: 2 (limit: 4722)
Memory: 1.2M
CGroup: /system.slice/mysqld.service
├─8360 /bin/sh /usr/bin/mysqld-post
└─8560 sleep 1
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:34.907694Z 0 [Warning] [MY-010139] [Server] Changed limits: >
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:34.907742Z 0 [Warning] [MY-010142] [Server] Changed limits: >
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.121790Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', >
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.121870Z 0 [System] [MY-010116] [Server] /usr/bin/mysqld (>
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.123947Z 0 [Warning] [MY-010091] [Server] Can't create tes>
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.123965Z 0 [Warning] [MY-010159] [Server] Setting lower_ca>
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.124479Z 0 [ERROR] [MY-010172] [Server] failed to set data>
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.124653Z 0 [ERROR] [MY-010119] [Server] Aborting
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.124793Z 0 [System] [MY-010910] [Server] /usr/bin/mysqld: >
5月 26 19:41:35 dexter0ion-pc systemd[1]: mysqld.service: Main process exited, code=exited, status=1/FAILURE
~