精华总结:MYSQL出现的问题解决记录:
不管通过什么方式安装(rpm或者gz或者gz.xz),安装顺序一定要对, 先在/etc/my.cfg文件先配置好,没有先创建这个文件,尽管放心,因为mysql启动会优先找这个文件作为参数启动。然后 进行mysql的初始化,初始化的时候可以带上路径等参数,这样
配置文件到时就不用配置这个了,配置了反而报错导致启动不起来,忽略密码等配置可以在初始化之后还能有效,其他的参数如路径初始化指定过了之后就不能在my.cfg用了,用重启一定报错。
如果不存在/etc/my.cfg 一定先建个,会优先调用这里的,否则调用$MYSQL_HOME/data 或者~等地方的my.cfg.
安装的时候如果提示
sudo yum install libstdc++.i686
Error: Protected multilib versions: libstdc+±4.4.7-16.el6.i686 != libstdc+±4.4.7-11.el6.x86_64
先执行 yum update libstdc+±4.4.7-16.el6.x86_64即可
初始化后还是报错说mysq pid找不到等错误:
考虑点:配置的mysql的路径是不是授权了,是不是my.cfg里面的参数设置问题导致启动不起来
如果mysql启动成功并且通过ip地址或者工具能连接,但是报错 比如transaction readonly等错误,这种考虑
是不是发布程序的mysql驱动和mysql数据库的版本是否对应
**
主要看上面的总结,下方为自己的测试笔记草稿,也可以参考
**
安装mysql 8.0.18 rmp centos 6版本
rpm -qa | grep mysql
rpm -e mysql //普通删除模式
rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
rpm -ivh mysql-community-common-8.0.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-8.0.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-8.0.11-1.el6.x86_64.rpm
mysql -V
service mysqld start
默认的datadir是在/var/lib/mysql/,可以通过修改my.cnf修改
发现没密码不能登录,于是添加skip-grant-tables到my.cnf,重启进去重置密码
flush privileges
alter user root@‘localhost’ identified by ‘root’;
service mysqld restart
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
show variables like ‘%pass%’;
drop user root@’localhost’
create user root@’localhost’ identified by ‘root’;
rant all on . to root@’localhost’ with grant option;
mysql -uroot -p -h192.168.1.193
select user,host,plugin from mysql.user;
需要在my.cnf里添加:default_authentication_plugin=mysql_native_password
service mysqld restart
mysql> drop user leo;
Query OK, 0 rows affected (0.10 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> create user leo identified by ‘mysql’;
Query OK, 0 rows affected (0.02 sec)
mysql> grant all on . to leo;
Query OK, 0 rows affected (0.08 sec)
show variables like ‘character%’;
/etc/rc.d/init.d/mysqld -stop
2.安装mysql8.0.18教程-centos7版https://www.jb51.net/article/175013.htm
rpm -qa | grep mariadb
rpm -e mariadb-libs-5.5.35-3.el7.x86_64 --nodeps
rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm
rpm -qa | grep mysql
chmod -R 777 /var/lib/mysql
先改配置文件然后启动
大小写配置vim /etc/my.cfg
lower_case_table_names=1
character-set-server=utf8
mysqld --initialize
初始化之后授权,否则启动不成功
chmod -R 777 /var/lib/mysql
systemctl start mysqld 开启mysql服务
systemctl status mysqld 查看mysql 状态
cat /var/log/mysqld.log | grep password 查看root初始密码
mysql -u root -p #回车之后输入前面的初始密码也就是 Iv7fjuP,ucH+(填自己的密码)
ALTER USER “root”@“localhost” IDENTIFIED BY “root”;
FLUSH PRIVILEGES; #立即生效
use mysql;
update user set host = ‘%’ where user =‘root’;
ALTER USER ‘root’@’%’ IDENTIFIED BY ‘root’ PASSWORD EXPIRE NEVER; #更改加密方式
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘root’; #更新用户密码 (我这里为root )
本
3.安装mysql8.0.18教程-linux通用解压缩版.txt
https://blog.csdn.net/github_39533414/article/details/80144890
先 xz -d xxx.tar.xz 将 xxx.tar.xz解压成 xxx.tar 然后,再用 tar xvf xxx.tar来解包。
xz -d mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz
tar -xvf mysql-8.0.18-linux-glibc2.12-x86_64.tar
apt-get install lib32stdc++6
For Red Hat :
sudo yum install libstdc++.i686
sudo yum install libstdc+±devel.i686
mkdir data
groupadd mysql
useradd -g mysql mysql
chown -R mysql.mysql /home/mysql/
或者
chown -R mysql .
chgrp -R mysql .
mkdir -p /home/mysql/data
/home/mysql/bin/mysqld --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data --initialize //初始化数据库
记录好自己的临时密码:
twi=Tlsi<0O!
yum install libnuma
yum -y install numactl
yum install libaio1 libaio-dev
cp /home/mysql/support-files/mysql.server /etc/init.d/mysqld
vim /etc/my.cnf
[mysqld]
basedir = /home/mysql
datadir = /home/mysql/data
socket = /home/mysql/mysql.sock
character-set-server=utf8
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket = /home/mysql/mysql.sock
default-character-set=utf8
chmod +x /etc/init.d/mysql
chkconfig --add mysql
chkconfig --list mysqld
vim /etc/profile
在 profile 文件底部添加如下两行配置,保存后退出
export PATH=$PATH:/home/mysql/bin:/home/mysql/lib
export PATH
设置环境变量立即生效
source /etc/profile
service mysql start
cat /root/.mysql_secret
mysql -uroot -p密码
SET PASSWORD FOR ‘root’@localhost=PASSWORD(‘123456’); #对应的换成你自己的密码即可了。
use mysql
update user set host=’%’ where user=‘root’ limit 1;
flush privileges;
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘root’;