mysql-5.7.23-el7-x86_64.tar安装配置_2018_lcf

下载安装包:https://dev.mysql.com/downloads/mysql/

22

下载好后,解压,我这里把mysql-5.7.23-el7-x86_64.tar 改名成了mysql5.7.23.tar.gz

33

解压后有两个解压包,只管mysql-5.7.23-el7-x86_64.tar.gz这个包,另一个是测试包不用管

[root@git /]# ls /
bin  boot  dev  etc  home  lib  lib64  media  mnt  mysql5.7.23.tar.gz  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

[root@git /]# tar -xf mysql5.7.23.tar.gz 
[root@git /]# ls
bin   dev  home  lib64  mnt                             mysql5.7.23.tar.gz                   opt   root  sbin  sys  usr
boot  etc  lib   media  mysql-5.7.23-el7-x86_64.tar.gz  mysql-test-5.7.23-el7-x86_64.tar.gz  proc  run   srv   tmp  var

[root@git /]# useradd -s /bin/false -d /usr/local/mysql/ mysql
//创建用户

[root@git /]# mkdir -p /usr/local/mysql/data
[root@git bin]# chown -R mysql.mysql /usr/local/mysql
//创建目录 (这里没装过数据库是没有mysql这个目录的)

[root@git /]# tar -xf mysql-5.7.23-el7-x86_64.tar.gz 
[root@git /]# cd mysql-5.7.23-el7-x86_64/
[root@git mysql-5.7.23-el7-x86_64]# ls
bin  COPYING  docs  include  lib  man  README  share  support-files

[root@git mysql-5.7.23-el7-x86_64]# cd bin/
[root@git bin]# ls
innochecksum    my_print_defaults           mysql_config         mysqldump         mysqlpump                  mysql_tzinfo_to_sql  resolve_stack_dump
lz4_decompress  mysql                       mysql_config_editor  mysqldumpslow     mysql_secure_installation  mysql_upgrade        zlib_decompress
myisamchk       mysqladmin                  mysqld               mysql_embedded    mysqlshow                  mysqlxtest
myisam_ftdump   mysqlbinlog                 mysqld-debug         mysqlimport       mysqlslap                  perror
myisamlog       mysqlcheck                  mysqld_multi         mysql_install_db  mysql_ssl_rsa_setup        replace
myisampack      mysql_client_test_embedded  mysqld_safe          mysql_plugin      mysqltest_embedded         resolveip

[root@git bin]# yum -y install libaio gcc make
//安装依赖包

[root@git bin]# ./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
2018-08-03T08:22:14.766220Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-03T08:22:14.768375Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2018-08-03T08:22:15.280059Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-08-03T08:22:15.372315Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-08-03T08:22:15.435202Z 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: 543f3d19-96f6-11e8-a609-525400603f3a.
2018-08-03T08:22:15.486161Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-08-03T08:22:15.486770Z 1 [Note] A temporary password is generated for root@localhost: wM<vlfOyU8kN
//到这里就安装完了,wM<vlfOyU8kN是密码,每次安装初始密码都不一样

修改配置

[root@git /]# vim /etc/my.cnf
[mysqld]
#skip-grant-tables
secure_file_priv="/usr/local/mysql"
port = 3306
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket=/tmp/mysql.sock
pid-file=/usr/local/mysql/data/mysql.pid
log-error=/usr/local/mysql/data/error.log
character_set_server=utf8
user=mysql
max_connections=1500
symbolic-links=0
!includedir /etc/my.cnf.d

启动服务

[root@git mysql-5.7.23-el7-x86_64]# pwd
/mysql-5.7.23-el7-x86_64

[root@git mysql-5.7.23-el7-x86_64]# ls
bin  COPYING  docs  include  lib  man  README  share  support-files

[root@git mysql-5.7.23-el7-x86_64]# cp support-files/mysql.server /etc/init.d/mysqld

[root@git mysql-5.7.23-el7-x86_64]# cp -r bin/ /usr/local/mysql/

[root@git mysql-5.7.23-el7-x86_64]# chown -R mysql:mysql /usr/local/mysql/

[root@git mysql-5.7.23-el7-x86_64]# cd /
[root@git /]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS! 

修改密码

[root@git /]# cd /usr/local/mysql/bin/
[root@git bin]# ls
innochecksum    my_print_defaults           mysql_config         mysqldump         mysqlpump                  mysql_tzinfo_to_sql  resolve_stack_dump
lz4_decompress  mysql                       mysql_config_editor  mysqldumpslow     mysql_secure_installation  mysql_upgrade        zlib_decompress
myisamchk       mysqladmin                  mysqld               mysql_embedded    mysqlshow                  mysqlxtest
myisam_ftdump   mysqlbinlog                 mysqld-debug         mysqlimport       mysqlslap                  perror
myisamlog       mysqlcheck                  mysqld_multi         mysql_install_db  mysql_ssl_rsa_setup        replace
myisampack      mysql_client_test_embedded  mysqld_safe          mysql_plugin      mysqltest_embedded         resolveip
[root@git bin]# ./mysql -uroot -p
Enter password: 

常见错误:

错误一:

mysql> set password=password("wM<vlfOyU8kN");
ERROR 1290 (HY000): Unknown error 1290
---先执行
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> set password=password("wM<vlfOyU8kN");
ERROR 1133 (42000): 
mysql> set password for root@localhost = password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

错误二:

[root@bakserver bin]# ./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

运行该命令后出现的报错如下:

 error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory


    出现该问题首先检查该链接库文件有没有安装使用 命令进行核查

    rpm -qa|grep libaio   

    运行该命令后发现系统中无该链接库文件

使用命令,yum install  libaio-devel.x86_64

安装成功后,继续运行数据库的初始化命令,提示成功。

猜你喜欢

转载自blog.csdn.net/cbuy888/article/details/81390177
今日推荐