检测mysql是否安装
rpm -qa|grep mysql
删除mysql
rpm -e mysql-libs-5.1.73-7.el6.x86_64
如果出现如下错误,就需要强制卸载mysql
error: Failed dependencies:
libmysqlclient.so.16()(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_7.1.x86_64
libmysqlclient.so.16(libmysqlclient_16)(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_7.1.x86_64
mysql-libs is needed by (installed) postfix-2:2.6.6-6.el6_7.1.x86_64
强制卸载mysql
rpm -ef mysql-libs-5.1.73-7.el6.x86_64 --nodeps
安装mysql服务器端
rpm -ivh MySQL-server-5.5.62-1.el6.x86_64.rpm
出现如下信息,说明安装成功
[root@luheng fengqing]# rpm -ivh MySQL-server-5.5.62-1.el6.x86_64.rpm
warning: MySQL-server-5.5.62-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
190319 16:38:29 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
190319 16:38:29 [Note] /usr/sbin/mysqld (mysqld 5.5.62) starting as process 5442 ...
190319 16:38:29 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
190319 16:38:29 [Note] /usr/sbin/mysqld (mysqld 5.5.62) starting as process 5449 ...
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h luheng password 'new-password'
Alternatively you can run:
/usr/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.
Please report any problems at http://bugs.mysql.com/
安装Mysql客户端
rpm -ivh MySQL-client-5.5.62-1.el6.x86_64.rpm
启动mysql
service mysql start
连接MySQL
mysql -u root -p
创建MySQL用户配置
cp /usr/share/mysql/my-small.cnf /etc/my.cnf
修改myql编码并重启服务
打开/etc/my.cnf文件,在mysqld的首行位置加入
character_set_server=utf8
开启3306端口
给用户授权远程登录并刷新权限
mysql> grant all privileges on *.* to root@'%' identified by '123456' with grant option;
刷新权限
mysql> flush provileges;