# centOS7.6下安装mysql # 在/usr/local 下建立mysql文件夹 rpm -qa | grep mariadb # 查看是否安装mariadb包 rpm -e XXXXXX --nodeps # 通过该命令卸载mariadb包 cd /usr/local/mysql # 进入mysql安装目录 wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar # 下载mysql8.0.11 tar -xvf mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar # 解压到当前目录
# 安装common
rpm -ivh mysql-community-common-8.0.11-1.el7.x86_64.rpm --nodeps --force
# 安装libs
rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm --nodeps --force
# 安装client
rpm -ivh mysql-community-client-8.0.11-1.el7.x86_64.rpm --nodeps --force
#安装server
rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm --nodeps --force
# 查看所有安装的包
rpm -qa | grep mysql # 初始化mysql mysqld --initialize;
chown mysql:mysql /var/lib/mysql -R;
systemctl start mysqld.service;
systemctl enable mysqld; cat /var/log/mysqld.log | grep password # 查看初始密码
进入到mysql交互界面中操作
修改root用户密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysql';
创建root用户
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root'; FLUSH PRIVILEGES; quit
###################################################################################离线包安装
yum -y install wget cmake gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel
参考博客
https://blog.csdn.net/qq_40181063/article/details/90713153
rpm -qa | grep mysql
yum remove mysql80-community-release-el7-1.noarch -y
mkdir /usr/local/mysql
mkdir /usr/local/data
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
cd /usr/local/mysql
chown -R mysql:mysql ./
vi /etc/my.cnf
[mysql] # 设置mysql客户端默认字符集 default-character-set=utf8 [mysqld] skip-name-resolve #设置3306端口 port = 3306 # 设置mysql的安装目录 basedir=/usr/local/mysql # 设置mysql数据库的数据的存放目录 datadir=/usr/local/mysql/data # 允许最大连接数 max_connections=200 # 服务端使用的字符集默认为8比特编码的latin1字符集 character-set-server=utf8 # 创建新表时将使用的默认存储引擎 default-storage-engine=INNODB lower_case_table_names=1 max_allowed_packet=16M default_authentication_plugin=mysql_native_password
tar -zxvf /root/apps/softs/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz -C /usr/local/mysql
cd /usr/local/mysql/mysql-8.0.11
bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data/
bin/mysqld_safe --user=mysql &
cat /var/log/mysqld.log | grep password
./bin/mysqld --user=mysql --basedir=/home/mysql/ --datadir=/home/mysql/data/ --initialize ;
./bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
./bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
./bin/mysqld_safe &
./bin/mysql -uroot -p
授权远程访问
set PASSWORD = 'mysql';
grant all privileges on *.* to 'python'@'%' with grant option;
GRANT ALL ON *.* TO 'root'@'%';
create user 'python'@'%' identified by 'qw123666';
ALTER USER 'python'@'%' IDENTIFIED WITH mysql_native_password BY 'qw123666';
GRANT ALL ON *.* TO 'python'@'%';
FLUSH PRIVILEGES;