#查找系统里面MySQL相关包,有就删除之
# rpm -qa | grep mysql #查找
[root@ecs-353814 ~]# rpm -qa | grep mysql
#rpm -e --nodeps 名称 #删除
[root@ecs-353814 ~]# rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64
#创建用户
useradd mysql
passwd mysql
#提前准备的安装包
mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz
进入 /home/mysql 目录,上传安装包
cd /home/mysql
#解压
tar -zxvf mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz
#移动安装目录
[root@ecs-353814 mysql]# mv /home/mysql/mysql-5.6.44-linux-glibc2.12-x86_64 /usr/local/mysql
cd /usr/local/mysql
#用户目录授权
chown mysql /usr/local/mysql
#初始化数据库
[root@ecs-353814 mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
#报错
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
#执行 yum -y install autoconf
[root@ecs-353814 mysql]# yum -y install autoconf
#再次初始化,还报错
Installing MySQL system tables.../usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
#执行 yum install libaio* -y
[root@ecs-353814 mysql]# yum install libaio* -y
#再初始化,出现以下信息
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:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h ecs-353814 password 'new-password'
Alternatively you can run:
/usr/local/mysql/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 . ; /usr/local/mysql/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/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
WARNING: Found existing config file /usr/local/mysql/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/local/mysql/my-new.cnf,
please compare it with your file and take the changes you need.
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
初始化数据库成功了!
#启动数据库
[root@ecs-353814 mysql]# ./support-files/mysql.server start
#失败信息
Starting MySQL.220309 09:36:18 mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'.
The server quit without updating PID file (/var/lib/mysql/e[失败]814.pid).
#执行以下操作
[root@ecs-353814 mysql]# mkdir /var/log/mariadb
[root@ecs-353814 mysql]# touch /var/log/mariadb/mariadb.log
[root@ecs-353814 mysql]# chown -R mysql:mysql /var/log/mariadb/
#再启动
[root@ecs-353814 mysql]# /usr/local/mysql/support-files/mysql.server start
#报错信息
Starting MySQL.220309 09:38:28 mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
The server quit without updating PID file (/var/lib/mysql/e[失败]814.pid).
#执行以下操作
[root@ecs-353814 mysql]# mkdir /var/lib/mysql
[root@ecs-353814 mysql]# chmod 777 /var/lib/mysql
#修改my.cnf
[root@ecs-353814 mysql]# vim /etc/my.cnf
datadir=/usr/local/mysql/data
#再启动
[root@ecs-353814 mysql]# /usr/local/mysql/support-files/mysql.server start
Starting MySQL. [ 确定 ]
成功了。
#修改root密码
[root@ecs-353814 bin]# ./mysqladmin -u root password 'root'
又报错
./mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
#修改 my.cnf 文件
[root@ecs-353814 bin]# vim /etc/my.cnf
socket=/tmp/mysql.sock
#重启mysql
[root@ecs-353814 ~]# /usr/local/mysql/support-files/mysql.server stop
Shutting down MySQL.. [ 确定 ]
[root@ecs-353814 ~]# /usr/local/mysql/support-files/mysql.server start
Starting MySQL. [ 确定 ]
#再修改密码
[root@ecs-353814 bin]# ./mysqladmin -u root password 'root'
Warning: Using a password on the command line interface can be insecure.
修改root密码成功。
#登录数据库
[root@ecs-353814 bin]# ./mysql -u root -p
#设置远程登录
mysql> grant all privileges on *.* to root@'%' identified by 'root';
Query OK, 0 rows affected (0.00 sec)
设置成功,至此远程Navicat就可以连接数据库了。