Linux系统下安装MySQL

48次阅读

共计 833 个字符,预计需要花费 3 分钟才能阅读完成。

操作系统: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’;

正文完
 0