linux 上mysql 5.7x安装

作者:吴泽鑫 分类: LNMP服务器 发布于:2018-11-29 1:47 ė122次浏览 60条评论

安装准备:

打开地址:http://dev.mysql.com/downloads/mysql

到mysql官网下载mysql编译好的二进制安装包,在下载页面Select Platform:选项,选择linux-generic,然后把页面拉到底部,64位系统下载Linux - Generic (glibc 2.12) (x86, 64-bit), Compressed TAR Archive

image.png

安装mysql 5.7.24

1.解压:tar zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz


2.复制:cp mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/webserver/mysql -r


3.添加系统mysql组和mysql用户:


执行命令:groupadd mysql和useradd -r -g mysql mysql


4.cd /usr/local/webserver/mysql


 chown -R mysql:mysql ./



 bin/mysqld --initialize --user=mysql --basedir=/usr/local/webserver/mysql/


 如果提示:bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

  解决:yum install libaio*


2018-11-28T17:23:33.013411Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2018-11-28T17:23:34.181116Z 0 [Warning] InnoDB: New log files created, LSN=45790

2018-11-28T17:23:34.298091Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2018-11-28T17:23:34.367132Z 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: 5587b3b2-f332-11e8-837e-00163e04a00c.

2018-11-28T17:23:34.369860Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2018-11-28T17:23:34.370343Z 1 [Note] A temporary password is generated for root@localhost: Y+4+6gk&<CXp

注意重点记录最后生成的登录密码


 bin/mysql_ssl_rsa_setup  --datadir=/usr/local/webserver/mysql/data


 vi /etc/my.cnf

 [mysqld]

 basedir =/usr/local/webserver/mysql

datadir =/usr/local/webserver/mysql/data

user=mysql

character_set_server=utf8


出现:Starting MySQL.2018-11-28T17:07:08.475271Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'.

解决:mkdir /var/log/mariadb

touch /var/log/mariadb/mariadb.log

chown -R mysql:mysql /var/log/mariadb/


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

chkconfig mysqld on # 设置开机自启动

chkconfig --list | grep mysqld


启动 重启 停止

service mysqld start

service mysqld restart

service mysqld stop


登陆

bin/mysql -uroot -p

数据刚才获取到的密码

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

修改 /etc/my.cnf 

socket=/tmp/mysql.sock 

并重启服务


登录成功,修改初始密码

mysql> show databases;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

修改密码

SET PASSWORD FOR 'root'@'localhost'=PASSWORD('newpassword');


本文出自 Jensen-吴泽鑫的博客,转载时请注明出处及相应链接:http://www.wuzexin.cn/post-70.html

发表评论

电子邮件地址不会被公开。必填项已用*标注


Ɣ回顶部