操作系统:manjaro
0.下载安装
sudo pacman -S mysql
1.初始化
sudo mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql
成功,在bash生成的信息区域倒数第二行末尾出现root@localhost: #!<J0rVb*klu
,这个就是初始用户名和初始密码.
1.5.如果这一步出错,没有生成初始的用户名和密码,就得卸载重装MySQL
#卸载
sudo pacman -Rs mysql
#删除MYSQL安装目录
sudo rm -rf /var/lib/mysql
然后再重新执行第一步.
2.设置MySQL开机自启
sudo systemctl enable mysqld.service
3.启动MySQL服务
sudo systemctl start mysqld.service
4.登录
mysql -u root -p
4.1.输入初始化密码
出现如下,即为成功:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 8.0.17 Source distribution
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
5.修改用户密码为666666,可自定
ALTER user 'root'@'localhost' IDENTIFIED BY '666666';
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。