查看操作系统信息
##uname -a
[root@ZJNB-receive1 mysql]# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 5.8 (Tikanga)
Release: 5.8
Codename: Tikanga
安装包:
MySQL-client-5.6.23-1.rhel5.x86_64.rpm
MySQL-server-5.6.23-1.rhel5.x86_64.rpm
groupadd mysql
useradd mysql -g mysql
安装服务端
rpm -ivh MySQL-server-5.6.23-1.rhel5.x86_64.rpm
rpm -ivh MySQL-client-5.6.23-1.rhel5.x86_64.rpm
启动服务
/etc/init.d/mysql start
/etc/init.d/mysql stop
Mysql>SET PASSWORD = PASSWORD('123456');
或者
update user set password=PASSWORD('123456') where user='root' and host='root' or host='localhost';
rpm安装默认目录:
数据文件:/var/lib/mysql/
配置文件模板:/usr/share/mysql
mysql客户端工具目录:/usr/bin
日志目录:/var/log/
pid,sock文件目录:/tmp/
修改数据文件路径
vi /etc/rc.d/init.d/mysql
datadir=/var/lib/mysql
注意:
Red Hat Enterprise Linux 5服务器上mysql启动报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
原因1-启动命令错误:
我开始的时候直接输入命令:mysql start
正确的启动命令是:
原因1-启动命令错误:
我开始的时候直接输入命令:mysql start
正确的启动命令是:
/etc/rc.d/init.d/mysql start
centos安装5.7
第一个:
rpm -ivh mysql-community-common-5.7.13-1.el7.x86_64.rpm
第二个:
rpm -ivh mysql-community-libs-5.7.13-1.el7.x86_64.rpm
第三个:
rpm -ivh mysql-community-client-5.7.13-1.el7.x86_64.rpm
第四个:
rpm -ivh mysql-community-server-5.7.13-1.el7.x86_64.rpm
mariadb-libs is obsoleted by mysql-community-libs-compat-5.7.17-1.el7.x86_64
卸载冲突包:
yum remove mariadb-libs-1*
CentOS7安装mysql5.7无法登陆问题。
在经过多次试验之后终于解决了root登录问题。解决步骤如下
$ sudo systemctl stop mysqld.service
$ sudo systemctl set-environment MYSQLD_OPTS="--user=mysql --skip-grant-tables --skip-networking"
$ sudo systemctl start mysqld.service
$ mysql -u root mysql
mysql > UPDATE mysql.user SET authentication_string=PASSWORD("abcdef") WHERE user='root' and host='localhost';
mysql > flush privileges;
mysql > quit
$ sudo systemctl unset-environment MYSQLD_OPTS
$ sudo systemctl restart mysqld.service