MySql教程

普华linux——mysql环境配置

本文主要是介绍普华linux——mysql环境配置,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

参考网址:
https://www.cnblogs.com/louis-liu-oneself/p/13504270.html
https://www.cnblogs.com/zero-gg/p/8875598.html
1、下载安装包
https://downloads.mysql.com/archives/community/
选择linux-generic,64位
tar -xzvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
2、卸载已安装的mysql
查询安装
rpm -qa | grep mysql
卸载
rpm -e --nodeps mysql-5.1.73-3.el6.isoft.x86_64
rpm -e --nodeps mysql-connector-odbc-5.1.5r1144-7.el6.isoft.x86_64
rpm -e --nodeps mysql-server-5.1.73-3.el6.isoft.x86_64
rpm -e --nodeps mysql-libs-5.1.73-3.el6.isoft.x86_64
rpm -e --nodeps mysql-devel-5.1.73-3.el6.isoft.x86_64
3、/usr/local 目录下创建文件夹存 mysql
mkdir /usr/local/mysql
cd
mv mysql-5.7.21-linux-glibc2.12-x86_64 /usr/local/mysql/

添加mysql组及用户
groupadd mysql
useradd -r -g mysql mysql

cd /usr/local/mysql/
mkdir /usr/local/mysql/data
vim /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=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
#lower_case_table_name=1
max_allowed_packet=16M

设置权限
chown -R root /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
chown -R mysql /usr/local/mysql/data

初始化MySQL
cd /usr/local/mysql/bin
./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --initialize
2022-02-09T19:32:08.766360Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-02-09T19:32:12.306161Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-02-09T19:32:12.778221Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-02-09T19:32:12.870257Z 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: fb039020-89de-11ec-8d0f-0cda411dae1d.
2022-02-09T19:32:12.876549Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-02-09T19:32:12.876984Z 1 [Note] A temporary password is generated for root@localhost: 5b8oNiAe+R4J

cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld

mkdir /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql/


vim /etc/profile
export PATH=/usr/local/mysql/bin:$PATH

登录
mysql -u root -p
set password for root@localhost = password('Sinosoft@2020');
UPDATE user SET authentication_string = PASSWORD("Sinosoft@2020") WHERE user='root' and host='%';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
FLUSH PRIVILEGES;
select user,host from mysql.user;

启动
service mysqld start
重启
service mysqld restart
停止
service mysqld stop

这篇关于普华linux——mysql环境配置的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!