微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

安装mysql5.7.23 (最新8.0.1)

如果出现问题请翻到最底部,会有可能出现的解决方


1.下载
wget: https://dev.MysqL.com/get/Downloads/MysqL-5.7/MysqL-5.7.23-linux-glibc2.12-x86_64.tar.gz

2、将MysqL安装到/usr/local/MysqL
# 解压
tar -xvf MysqL-5.7.23-linux-glibc2.12-x86_64.tar.gz

# 移动
mv MysqL-5.7.23-linux-glibc2.12-x86_64 /usr/local/

# 重命名
mv /usr/local/MysqL-5.7.23-linux-glibc2.12-x86_64  /usr/local/MysqL

3.新建data目录
mkdir /usr/local/MysqL/data

4、新建MysqL用户MysqL用户
# MysqL用户
groupadd MysqL

# MysqL用户
useradd MysqL -g MysqL

5、将/usr/local/MysqL的所有者及所属组改为MysqL
chown -R MysqL.MysqL /usr/local/MysqL


6、配置(实列化成功会出现密码root@localhost: q9fSP9uRDa-R)
/usr/local/MysqL/bin/MysqL_install_db --user=MysqL --basedir=/usr/local/MysqL/ --datadir=/usr/local/MysqL/data

#如果报错, 则使用以下命令:
/usr/local/MysqL/bin/MysqLd --user=MysqL --basedir=/usr/local/MysqL/ --datadir=/usr/local/MysqL/data --initialize
或者
bin/MysqLd --initialize --user=MysqL --basedir=/usr/local/MysqL --datadir=/usr/local/MysqL/data --lc_messages_dir=/usr/local/MysqL/share --lc_messages=en_US

7.添加my.cnf(5.7.23没有认my.cnf需要自己配置)
vi /etc/my.cnf
[MysqL]  
# 设置MysqL客户端认字符集  
default-character-set=utf8   
socket=/var/lib/MysqL/MysqL.sock  
[MysqLd]  
#skip-name-resolve  
#设置3306端口  
port = 3306   
socket=/var/lib/MysqL/MysqL.sock  
# 设置MysqL的安装目录  
basedir=/usr/local/MysqL  
# 设置MysqL数据库的数据的存放目录  
datadir=/usr/local/MysqL/data  
# 允许最大连接数  
max_connections=10000  
# 服务端使用的字符集认为8比特编码的latin1字符集  
character-set-server=utf8  
# 创建新表时将使用的认存储引擎  
default-storage-engine=INNODB  
#lower_case_table_name=1  
max_allowed_packet=16M

8.开机启动

加入服务
cp /usr/local/MysqL/support-files/MysqL.server /etc/init.d/MysqL
# 开机自启
chkconfig MysqL on
# 开启
service MysqL start

9.登录MysqL修改密码(之前实列化有密码)
MysqL -u root -p 
修改密码
set password = password('密码')

10.允许远程访问
MysqL -u root -p
use MysqL;
update user set host='%' where user = 'root';
flush privileges;
eixt;

 

 

 

***************** 可能出现问题和解决方案 *******************

二进制安装MysqL初始化出现:Installing MysqL system tables.../usr/local/MysqL/bin/MysqLd: error while loading shared

原因:缺少libaio库文件

解决方法:yum install libaio* -y

 

出现:Starting MysqL.2019-11-13T01:52:46.980719Z MysqLd_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'MysqL'.

The server quit without updating PID file (/usr/local/MysqL[Failed]bp1629dthbt44srhzw93Z.pid).

解决方

1、mkdir /var/log/mariadb
2、touch /var/log/mariadb/mariadb.log
3、chown -R MysqL:db /var/log/mariadb/
4、chown -R MysqL:db /var/log/mariadb/mariadb.log
5、chown -R MysqL:MysqL /var/log/mariadb/mariadb.log

 

出现:MysqLd_safe Directory '/var/lib/MysqL' for UNIX socket file don't exists.

解决方

1、 mkdir /var/lib/MysqL
2、chmod 777 /var/lib/MysqL

 

出现:-bash: MysqL: command not found

解决方

1、ln -s /usr/local/MysqL/bin/MysqL /usr/bin

 

出现:You must reset your password using ALTER USER statement before executing this statement

解决方案:

ALTER USER USER() IDENTIFIED BY '密码';

 

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐