一、下载mysql-5.6.30-linux-glibc2.5-x86_64.tar.gzmysql
二、解压到安装目录linux
#解压
tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gzsql
#添加目录数据库
mkdir -p /usr/local/mysql服务器
#复制解压后的mysql目录
cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/socket
三、添加用户组和用户测试
#添加用户组
groupadd mysql
#添加用户mysql 到用户组mysql
useradd -g mysql mysqlui
四、安装this
1)、cd /usr/local/spa
2)、rename mysql-5.6.30-linux-glibc2.5-x86_64 mysql *
3)、cd /usr/local/mysql/
4)、mkdir -p ./data/mysql
5)、chown -R mysql:mysql ./
6)、./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql (错误1)
7)、cp support-files/mysql.server /etc/init.d/mysqld (错误2)
8)、chmod 755 /etc/init.d/mysqld
9)、cp support-files/my-default.cnf /etc/my.cnf
10)、 #修改启动脚本
vi /etc/init.d/mysqld
11)、#修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
12)、#启动服务
service mysqld start
13)、#测试链接
./mysql/bin/mysql -uroot
14)、#加入环境变量,编辑 /etc/profile,这样能够在任何地方用mysql命令了
export PATH=$PATH:/usr/local/mysql//bin source /etc/profile
说明:
#启动mysql service mysqld start
#关闭mysql service mysqld stop
#查看运行状态 service mysqld status
备注:安装过程遇到错误莫要慌张
错误一、FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
解决方法 :安装autoconf库 命令:yum-y install autoconf
错误二、Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
当咱们使用“mysql_install_db”安装MySQL时,须要libaio包,现将不一样Linux系统安装该包的方式总结以下:
一、对于Redhat/CentOS系统用以下安装方式:[root@dbhost01~]# yum install libaio
二、对Debian系统用以下安装方式:root@dbhost01:~# apt-get install libaio1
远程访问注意事项:
远程访问时须要密码安装全程没有设置过密码就须要修改密码了
中止msql服务
ps -ef|grep mysql
杀死进程 kill -9 8389
2.修改MySQL的登陆设置:
# vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
保存而且退出vi。
3.从新启动mysqld
# service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
4.登陆并修改MySQL的root密码
# ./mysql/bin/mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.56
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> USE mysql ;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
5.将MySQL的登陆设置修改回来
# vi /etc/my.cnf
将刚才在[mysqld]的段中加上的skip-grant-tables删除
保存而且退出vi。
6.从新启动mysqld
# service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
链接时,报1130错误,是因为没有给远程链接的用户权限问题
解决1:更改 ‘mysql’数据库‘user’表‘host’项,从‘localhost’改为‘%’。
use mysql;
select 'host' from user where user='root';
update user set host = '%' where user ='root';
flush privileges;
解决2:直接受权
GRANT ALL PRIVILEGES ON *.* TO ‘root’@'%’ IDENTIFIED BY ‘youpassword’ WITH GRANT OPTION;
云服务器端口没开放问题