.Linux下MySQL的安装-解压缩安装

1.Linux安装MySQL解压缩版,首先先下载MySQL解压缩版我们可以在官网下载MySQL解压缩版
mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz上传到服务器即可
2.解压缩下载的MySQL包
[root@192 Downloads]# tar  -zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
下面是部分解压缩信息
mysql-5.7.18-linux-glibc2.5-x86_64/bin/myisam_ftdump
mysql-5.7.18-linux-glibc2.5-x86_64/bin/myisamchk
mysql-5.7.18-linux-glibc2.5-x86_64/bin/myisamlog
mysql-5.7.18-linux-glibc2.5-x86_64/bin/myisampack
mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysql
mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysql_client_test_embedded
mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysql_config_editor
mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysql_embedded
mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysql_install_db
mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysql_plugin
mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysql_secure_installation
mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysql_ssl_rsa_setup
mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysql_tzinfo_to_sql
mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysql_upgrade
mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysqladmin
mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysqlbinlog
3.将解压缩文件移动到usr/local/mysql下,并创建mysql数据文件夹
[root@192 Downloads]# mv mysql-5.7.18-linux-glibc2.5-x86_64 /usr/local/mysql
root@192 local]# mkdir mysql/data
4.创建mysql的用户组和用户,并对mysql目录设置用户组和用户
[root@192 local]# groupadd mysql
[root@192 local]#  useradd mysql -g mysql
[root@192 local]# cd mysql
[root@192 mysql]# pwd
/usr/local/mysql
[root@192 mysql]# chown -R mysql .
[root@192 mysql]# chgrp -R mysql .
5.初始化MySQL并启动MySQL服务
[root@192 mysql]# cd /usr/local/mysql/bin
libaio如果没有安装将会安装,安装过后不会再次安装
[root@192 bin]# yum install libaio
Loaded plugins: fastestmirror, langpacks
base                                                             | 3.6 kB  00:00:00     
extras                                                           | 3.4 kB  00:00:00     
updates                                                          | 3.4 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                    | 155 kB  00:00:01     
(2/4): extras/7/x86_64/primary_db                                | 139 kB  00:00:01     
(3/4): base/7/x86_64/primary_db                                  | 5.6 MB  00:00:02     
(4/4): updates/7/x86_64/primary_db                               | 4.7 MB  00:00:03     
Determining fastest mirrors
 * base: mirrors.sohu.com
 * extras: mirrors.sohu.com
 * updates: mirrors.163.com
Package libaio-0.3.109-13.el7.x86_64 already installed and latest version
Nothing to do
[root@192 bin]#  ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
2017-04-19 04:33:15 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2017-04-19 04:33:22 [WARNING] The bootstrap log isn't empty:
2017-04-19 04:33:22 [WARNING] 2017-04-19T11:33:16.350809Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2017-04-19T11:33:16.351453Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2017-04-19T11:33:16.351467Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
[root@192 bin]#  ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
2017-04-19 04:33:15 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2017-04-19 04:33:22 [WARNING] The bootstrap log isn't empty:
2017-04-19 04:33:22 [WARNING] 2017-04-19T11:33:16.350809Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2017-04-19T11:33:16.351453Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2017-04-19T11:33:16.351467Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

[root@192 bin]# cd /usr/local/mysql/support-files
[root@192 support-files]#  ./mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/192.168.226.130.err'.
 SUCCESS! 
6.登录MySQL
由于此版本密码不能为空所以解压时会有默认密码使用下面命令查看密码
[root@192 support-files]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2017-04-19 04:33:15 
n-K,BLg4U)fD
登录MySQL时会出现下面错误,建立一个链接即可
[root@192 support-files]# mysql -uroot -p
bash: mysql: command not found...
[root@192 support-files]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

下面就会登录MySQL,我们可以自己修改用户密码。
[root@192 support-files]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18

Copyright (c) 2000, 2017, 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> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
我们可以使用下面的命令修改密码
mysql> set password=password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

未配置的情况下每次登录需要进入bin目录下操作:
7.复制配置文件
[root@192 /]# cp support-files/mysql.server /etc/init.d/mysqld
开机自启动
[root@192 mysql]# chkconfig --add mysqld
[root@192 mysql]# chkconfig --list mysqld

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

mysqld             0:off    1:off    2:on    3:on    4:on    5:on    6:off
[root@192 etc]# service mysqld start
Starting MySQL. SUCCESS! 
8.登录MySQL
[root@192 etc]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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> 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值