在官网下载MySQL安装包 , 然后上传到/usr/local
[root@bogon local]# tar -zxvf mysql-5.5.61-linux-glibc2.12-x86_64.tar.gz
[root@bogon local]# mv mysql-5.5.61-linux-glibc2.12-x86_64 mysql
添加mysql用户组
[root@bogon mysql]# groupadd mysql
添加mysql用户
[root@bogon mysql]# useradd -g mysql mysql
更改mysql目录所属用户组和用户
[root@bogon local]# chown -R mysql:mysql /usr/local/mysql
[root@bogon local]# cd mysql
执行mysql安装脚本
[root@bogon mysql]# ./scripts/mysql_install_db --user=mysql
WARNING: The host 'bogon' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
180914 12:51:06 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
180914 12:51:06 [Note] ./bin/mysqld (mysqld 5.5.61) starting as process 6883 ...
OK
Filling help tables...
180914 12:51:07 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
180914 12:51:07 [Note] ./bin/mysqld (mysqld 5.5.61) starting as process 6890 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h bogon password 'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
开机启动mysqld服务
[root@bogon mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@bogon mysql]# chkconfig --add mysqld
[root@bogon mysql]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
启动mysqld服务
[root@bogon mysql]# service mysqld start
Starting MySQL.. SUCCESS!
查看mysqld服务状态
[root@bogon mysql]# service mysqld status
SUCCESS! MySQL running (7175)
建立软链接
[root@bogon mysql]# ln -s /usr/local/mysql/bin/mysql /usr/local/bin/
[root@bogon mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.61 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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>
mysql> exit
[root@bogon mysql]# cd /usr/local/mysql/bin/
设置root用户密码
[root@localhost bin]# ./mysqladmin -u root password '123456'
开放3306端口
[root@localhost bin]# vi /etc/sysconfig/iptables
在 -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT的下面添加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
[root@localhost bin]# service iptables restart