linux 安装 mysql-5.6.26

linux安装mysql-5.6.26

 查看工具:winscp

下载地址

http://mirrors.sohu.com/mysql/MySQL-5.6/ 

 文件: mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz

解压

tar -xzf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz

注:安装目录需要设置到解压目录,否则报以下错误

FATAL ERROR: Could not find ./bin/my_print_defaults

If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

or

FATAL ERROR: Could not find my-default.cnf

If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

 将解压的目录放到/usr/local下改为mysql或添加软连接

mv mysql-5.6.26-linux-glibc2.5-x86_64 mysql

or

ln -s  /www/mysql-5.6.26-linux-glibc2.5-x86_64 /usr/local/mysql

增加mysql用户和组

groupadd mysql
useradd -r -g mysql mysql

修改mysql目录及子文件属主和属组

chown -R mysql:mysql mysql

进入mysql目录并安装

cd mysql
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

安装过程可能缺少某些文件,一般用 yum install -y xxx 按需安装即可.

实现使用 service mysqll (start|status|stop) 命令操作mysql.

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

错误:

[root@localhost mysql]# mysql
-bash: mysql: command not found

解决:配置环境变量,把 export PATH=$PATH:/usr/local/mysql/bin添加到 /etc/profile中, source /etc/profile重新加载环境变量, service mysql start启动mysql服务。

错误:

[root@localhost mysql]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

解决:

mysql --socket=/var/lib/mysql/mysql.sock
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

启动成功

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.26 |
+-----------+
1 row in set (0.00 sec)

成功后可能需要往mysql的user表增加新账号

错误:指定了严格模式,为了安全,严格模式禁止通过insert 这种形式直接修改mysql库中的user表进行添加新用户

1364 - Field 'ssl_cipher' doesn't have a default value

解决:

vim /usr/local/mysql/my.cnf
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
改为
sql_mode=NO_ENGINE_SUBSTITUTION

修改密码:
mysql>UPDATE user SET password=PASSWORD('1') where USER='root';
  允许使用用户名root密码1从任何主机连接到mysql服务器
  该创建的root账号只是从外部访问的账号,与内部linux访问该mysql时所用root不同,内部linux访问该mysql的root账号也不是linux的系统root账号
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '1' WITH GRANT OPTION;

刷新权限
mysql>FLUSH PRIVILEGES;

MySql提示:The server quit without updating PID file(…)失败
可能进程里已经存在mysql进程
解决方法:用命令“ps -ef|grep mysqld”查看是否有mysqld进程,如果有使用“kill -9  进程号”杀死,然后重新启动mysqld!

查看CentOS linux版本: cat /etc/issue

root@DB-02 ~]# mysql -u root
-bash: mysql: command not found

原因:这是由于系统默认会查找/usr/bin下的命令,如果这个命令不在这个目录下,当然会找不到命令,我们需要做的就是映射一个链接到/usr/bin目录下,相当于建立一个链接文件。
首先得知道mysql命令或mysqladmin命令的完整路径,比如mysql的路径是:/usr/local/mysql/bin/mysql,我们则可以这样执行命令:

# ln -s /usr/local/mysql/bin/mysql /usr/bin

posted @ 2015-09-14 17:17  zping  阅读(2576)  评论(0编辑  收藏  举报