欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

OEL7.6源码安装MYSQL5.7的教程

程序员文章站 2022-04-06 09:52:43
首先官网下载安装包 然后上传解压至/usr/local目录 [root@localhost db]# tar -xf mysql-5.7.26-linux-...

首先官网下载安装包

OEL7.6源码安装MYSQL5.7的教程

然后上传解压至/usr/local目录

[root@localhost db]# tar -xf mysql-5.7.26-linux-glibc2.12-x86_64.tar 
[root@localhost db]# tar -xzf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz 
[root@localhost db]# mv mysql-5.7.26-linux-glibc2.12-x86_64 /usr/local/mysql
[root@localhost db]# 

然后创建mysql用户和组以及数据目录

[root@localhost db]# mv mysql-5.7.26-linux-glibc2.12-x86_64 /usr/local/mysql
[root@localhost db]# groupadd mysql
[root@localhost db]# useradd mysql -g mysql
[root@localhost db]# cd /usr/local/mysql
[root@localhost mysql]# mkdir data
[root@localhost mysql]# chown mysql: -r /usr/local/mysql/
[root@localhost mysql]# 

然后初始化数据并记录临时密码

[root@localhost mysql]# bin/mysqld --initialize --user=mysql --datadir /usr/local/mysql/data
2019-07-26t01:34:24.479757z 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-07-26t01:34:24.682695z 0 [warning] innodb: new log files created, lsn=45790
2019-07-26t01:34:24.717419z 0 [warning] innodb: creating foreign key constraint system tables.
2019-07-26t01:34:24.723157z 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: 8009a802-af45-11e9-839c-000c29984aae.
2019-07-26t01:34:24.723996z 0 [warning] gtid table is not ready to be used. table 'mysql.gtid_executed' cannot be opened.
2019-07-26t01:34:24.724629z 1 [note] a temporary password is generated for root@localhost: ucz5w5zksq;1
[root@localhost mysql]#

然后修改/etc/my.cnf配置文件中datadir为/usr/local/mysql/data 

[root@localhost mysql]# cat /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
[root@localhost mysql]# 

然后将mysql加入init.d目录并启动mysql

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# /etc/init.d/mysqld start
starting mysql.logging to '/usr/local/mysql/data/localhost.localdomain.err'.
 success! 
[root@localhost mysql]# ps -ef|grep mysql
root   12957   1 0 09:37 pts/0  00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/localhost.localdomain.pid
mysql  13057 12957 4 09:37 pts/0  00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/usr/local/mysql/data/localhost.localdomain.pid
root   13092 10198 0 09:37 pts/0  00:00:00 grep --color=auto mysql
[root@localhost mysql]# 

最后mysql/bin加入path,并登陆数据库并重设密码

[root@localhost bin]# ./mysql -u root -p
enter password: 
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id is 2
server version: 5.7.26
copyright (c) 2000, 2019, oracle and/or its affiliates. all rights reserved.
oracle is a registered trademark of oracle corporation and/or its
affiliates. other names may be trademarks of their respective
owners.
type 'help;' or '\h' for help. type '\c' to clear the current input statement.
mysql> set password=password('mysql');
query ok, 0 rows affected, 1 warning (0.00 sec)
mysql> exit
bye
[root@localhost bin]# ./mysql -u root -p
enter password: 
error 1045 (28000): access denied for user 'root'@'localhost' (using password: yes)
[root@localhost bin]# ./mysql -u root -p
enter password: 
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id is 4
server version: 5.7.26 mysql community server (gpl)
copyright (c) 2000, 2019, oracle and/or its affiliates. all rights reserved.
oracle is a registered trademark of oracle corporation and/or its
affiliates. other names may be trademarks of their respective
owners.
type 'help;' or '\h' for help. type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| database      |
+--------------------+
| information_schema |
| mysql       |
| performance_schema |
| sys        |
+--------------------+
4 rows in set (0.01 sec)
mysql> 

ojbk,then have fun!

总结

以上所述是小编给大家介绍的oel7.6源码安装mysql5.7的教程,希望对大家有所帮助