【安装】Linux mysql-5.7.9源码安装
2018年06月16日 09:29:22 作者:Jiaozn 分类:MySQL 评论(0)安装版本:mysql-5.7.9-linux-glibc2.5-i686 (二进制包)
操作环境:Red Hat Enterprise Linux Server release 5.8 (Tikanga)
(lsb_release -a)
安装步骤:
准备:创建mysql组和用户
[root@hucc /]#groupadd mysql
[root@hucc /]#useradd -r -g mysql mysql
1.rz将mysql安装包传到虚拟机的/usr/local/src
[root@hucc src]# tar zxvf mysql-5.7.9-linux-glibc2.5-i686.tar
[root@hucc src]#cp mysql-5.7.9-linux-glibc2.5-i686 /usr/local/mysql/
[root@hucc local]#chown –R mysql:mysql mysql
[root@hucc mysql]# mkdir data
[root@hucc mysql]#pwd
/var/lib/mysql
[root@hucc mysql]#chown –R mysql:mysql data
[root@hucc mysql]#su mysql
[mysql@hucc /]$ /usr/local/mysql/bin/mysql_install_db --user=mysql --datadir=/var/lib/mysql/data
2.安装数据库
[mysql@hucc mysql]$ /usr/local/mysql/bin/mysql_install_db --user=mysql --datadir=/var/lib/mysql/data/
2015-11-11 11:16:51 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2015-11-11 11:17:02 [WARNING] The bootstrap log isn't empty:
2015-11-11 11:17:02 [WARNING] 2015-11-11T03:16:51.695249Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2015-11-11T03:16:51.696235Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2015-11-11T03:16:51.696248Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
注:datadir 参数:该参数指定了 MySQL 的数据库文件放在什么路径下。数据库文件即我们常说的 MySQL data 文件
basedir 参数:该参数指定了安装 MySQL 的安装路径,填写全路径可以解决相对路径所造成的问题。
每次执行命令,都要注意这两个参数的路径是否正确
3.初始化数据库
[mysql@hucc data]$ /usr/local/mysql/bin/mysqld --initialize --datadir=/var/lib/mysql/data/
2015-11-11T03:21:48.753914Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2015-11-11T03:21:48.754043Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2015-11-11T03:21:48.754228Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-11-11T03:21:53.407740Z 0 [Warning] InnoDB: New log files created, LSN=45790
2015-11-11T03:21:53.835859Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-11-11T03:21:53.902132Z 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: 5b2484fb-8823-11e5-861b-000c2939111e.
2015-11-11T03:21:53.906476Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2015-11-11T03:21:53.934071Z 1 [Note] A temporary password is generated for root@localhost: gp1qA233.s4W
问题:
[mysql@hucc mysql]$ /usr/local/mysql/bin/mysqld --initialize --datadir=/var/lib/mysql/data/
2015-11-11T03:19:58.580635Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2015-11-11T03:19:58.580897Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2015-11-11T03:19:58.581086Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-11-11T03:19:58.583953Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2015-11-11T03:19:58.584183Z 0 [ERROR] Aborting
处理方法
cd /var/lib/mysql/data 目录下执行 rm –rf *
在安装前执行过这个步骤,为什么初始化还要再执行一次
4.启动mysql服务
[mysql@huccmysql]$/usr/local/mysql/bin/mysqld_safe --basedir=/usr/local/mysql --datadir=/var/lib/mysql/data/
151111 11:48:24 mysqld_safe Logging to '/var/lib/mysql/data//hucc.com.err'.
151111 11:48:24 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql/data/
[mysql@hucc root]$ /usr/local/mysql/bin/mysqld_safe --basedir=/usr/local/mysql --datadir=/var/lib/mysql/data/
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
grep: write error: 断开的管道
151111 11:52:27 mysqld_safe Logging to '/var/lib/mysql/data//hucc.com.err'.
151111 11:52:27 mysqld_safe A mysqld process already exists
[mysql@hucc root]$ netstat -altn | grep 3306
tcp 0 0 :::3306 :::* LISTEN
[mysql@hucc root]$ /usr/local/mysql/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.9
Copyright (c) 2000, 2015, 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 for root@localhost=password('asd123');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> exit
Bye
修改密码 set password for root@localhost=password('asd123');
评论
发表评论