MySQL安装的体会,Linux 安装mysql心得

第一步:mysql安装包准备

第二步:将mysql安装包上传到服务器

bd0d99f283cc06bbfaa55098098a4c6a.png

第三步:解压

tar -zxvf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz

第四步:cp或mv到/usr/local/目录下,并命名为mysql

注意:这里不建议使用拷贝(cp),因为文件大的话就会很慢

mv mysql-5.7.30-linux-glibc2.12-x86_64 /usr/local/mysql

第五步:创建mysql用户组和用户

groupadd mysql

useradd -r -g mysql mysql

第六步:创建mysql配置存放目录data

cd /usr/local/mysql

mkdir data

第七步:为mysql目录修改用户权限

chown -R mysql:mysql /usr/local/mysql/

第八步:将mysql初始化,并记录初始密码(Bo39?ed2h*W1)

cd msyql/bin

./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

会出现以下:

2021-01-30T03:51:20.337410Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2021-01-30T03:51:21.458335Z 0 [Warning] InnoDB: New log files created, LSN=45790

2021-01-30T03:51:21.659739Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2021-01-30T03:51:21.722351Z 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: 6a99bae9-62ae-11eb-8966-00163e175cc4.

2021-01-30T03:51:21.724337Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2021-01-30T03:51:22.941639Z 0 [Warning] CA certificate ca.pem is self signed.

2021-01-30T03:51:22.977097Z 1 [Note] A temporary password is generated for root@localhost: Bo39?ed2h*W1

第九步:配置mysql(my.cnf)

vim /etc/my.cnf

[mysqld]

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

#skip-grant-tables

port = 3306

pid-file = /usr/local/mysql/data/mysql.pid

socket = /usr/local/mysql/data/mysql.sock

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

default_authentication_plugin = mysql_native_password

第十步:加入开机自启

cd /usr/local/mysql

cp support-files/mysql.server /etc/init.d/mysql

chmod +x /etc/init.d/mysql //添加可执行权限

chkconfig --add mysql // 添加开机自启

chkconfig --list //查看自启是否添加成功

ecbcd6810f800b7c74e7eebea51d5969.png

第十一步:配置环境变量

vim /etc/profile

export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib

source /etc/profile

第十二步:启动mysql

systemctl restart mysql

第十三步:登录mysql

mysql -u root -pBo39?ed2h*W1 //初始化密码

会出现以下错误(说是要改一下/tmp/mysql.sock目录):

ee22bb97c93862405011af66d9591326.png

vim /etc/my.cnf

socket = /tmp/mysql.sock

systemctl restart mysql //再重启服务

再次登录:(mysql -u root -pBo39?ed2h*W1)

ffd7e94a23a22b0674e638ac89f4561a.png

修改密码

alter user 'root'@'localhost' identified with mysql_native_password by '123456';

或 set password for root@localhost= password(‘123456’);

flush privileges;

ba66e0eb6f4fe36c1bc9b900fcf2ca68.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值