Mysql5.5二进制包安装

时间:2023-01-31 20:59:03

Mysql5.5二进制包安装过程

安装环境

1 [root@minlian tools]# cat /etc/redhat-release
2 CentOS release 6.5 (Final)
3 [root@minlian tools]# uname -r
4 2.6.32-431.el6.x86_64
5 [root@minlian tools]# uname -m
6 x86_64

下载以及解压缩过程

1 [root@minlian tools]#  wget --no-check-certificate https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz
 2 [root@minlian tools]# tar xf mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz 
 3 [root@minlian mysql]# mkdir -p /application/
 4 [root@minlian tools]# mv mysql-5.5.57-linux-glibc2.12-x86_64 /application/mysql-5.5.57
 5  [root@minlian tools]# ln -s /application/mysql-5.5.57/ /application/mysql
 6 [root@minlian tools]# cd /application/mysql
 7 [root@minlian mysql]# ls -l support-files/*.cnf
 8 -rw-r--r-- 1 7161 31415 4691 6月 5 15:21 support-files/my-huge.cnf 9 -rw-r--r-- 1 7161 31415 19759 6月 5 15:21 support-files/my-innodb-heavy-4G.cnf 10 -rw-r--r-- 1 7161 31415 4665 6月 5 15:21 support-files/my-large.cnf 11 -rw-r--r-- 1 7161 31415 4676 6月 5 15:21 support-files/my-medium.cnf 12 -rw-r--r-- 1 7161 31415 2840 6月 5 15:21 support-files/my-small.cnf
13
[root@minlian mysql]#/bin/cp support-files/my-small.cnf /etc/my.cnf 

 

初始化数据库文件

1 [root@minlian mysql]# useradd -s /sbin/nologin -M mysql
2 [root@minlian mysql]# id mysql
3 uid=503(mysql) gid=503(mysql) 组=503(mysql)
4 [root@minlian mysql]# chown -R /application/mysql/
5 [root@minlian mysql]# mkdir -p /application/mysql/data
6 [root@minlian mysql]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql

配置并启动Mysql数据库

 1 [root@minlian mysql]# /etc/init.d/mysqld start
 2 Starting MySQL.Logging to '/application/mysql/data/minlian.minliandomain.err'.
 3 .. [确定]
 4 [root@minlian mysql]# netstat -lntup|grep mysql
 5 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2105/mysqld
 6 [root@minlian mysql]# chkconfig --add mysqld
 7 [root@minlian mysql]# chkconfig mysqld on
 8 [root@minlian mysql]# chkconfig --list mysqld
 9 mysqld 0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭
10 [root@minlian mysql]# echo 'export PATH=/application/mysql/bin:$PATH' >> /etc/profile
11 [root@minlian mysql]# source /etc/profile
12 [root@minlian mysql]# echo $PATH
13 /application/mysql/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

登录mysql测试

 1 [root@minlian mysql]# mysql
 2 mysql> show databases;
 3 +--------------------+
 4 | Database 
 5 +--------------------+
 6 | information_schema 
 7 | mysql 
 8 | performance_schema 
 9 | test 
10 +--------------------+
11 4 rows in set (0.00 sec)
12 mysql> select user();
13 +----------------+
14 | user() 
15 +----------------+
16 | root@localhost 
17 +----------------+
18 1 row in set (0.00 sec)
19 mysql> select user,host from mysql.user;
20 +------+-----------------------+
21 | user | host 
22 +------+-----------------------+
23 | root | 127.0.0.1 
24 | root | ::1 
25 |      | localhost 
26 | root | localhost 
27 |      | minlian.minliandomain 
28 | root | minlian.minliandomain 
29 +------+-----------------------+
30 6 rows in set (0.00 sec)
31 mysql> quit
32 Bye

为Mysql的root用户设置密码,清理无用的Mysql用户及库

 1 [root@minlian mysql]# mysqladmin -uroot password 'oldboy123'
 2 [root@minlian mysql]# mysql -uroot -poldboy123
 3 mysql> select user,host from mysql.user;
 4 +------+-----------------------+
 5 | user | host 
 6 +------+-----------------------+
 7 | root | 127.0.0.1 
 8 | root | ::1 
 9 |      | localhost 
10 | root | localhost 
11 |      | minlian.minliandomain 
12 | root | minlian.minliandomain 
13 +------+-----------------------+
14 6 rows in set (0.00 sec)
15 mysql> drop user "root"@"::1";
16 Query OK, 0 rows affected (0.00 sec)
17 mysql> drop user ""@"localhost";
18 Query OK, 0 rows affected (0.00 sec)
19 mysql> drop user ""@"minlian.minliandomain";
20 Query OK, 0 rows affected (0.00 sec)
21 mysql> drop user "root"@"minlian.minliandomain";
22 Query OK, 0 rows affected (0.00 sec)
23 mysql> select user,host from mysql.user;
24 +------+-----------+
25 | user | host 
26 +------+-----------+
27 | root | 127.0.0.1 
28 | root | localhost 
29 +------+-----------+
30 2 rows in set (0.00 sec)