Linux下安装MySql(版本5.5以上)
2015-09-09 15:22
459 查看
开始使用未编译版本(参考:http://www.iteye.com/topic/1128407,注:MySQL5.5以上,安装方法与以前的不同),结果麻烦多多,错误多多。后改用已编译版,方便多了。详细如下(此版依赖libc特定版本,如想通用又不想编译虽用rpm安装,参见http://blog.csdn.net/superchanon/article/details/8546254/):
从这里下载:http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz(更多不同版本下载见:http://mirrors.sohu.com/mysql/MySQL-5.6/)
先查看linux libc 版本是否一致:
ls -l /lib/libc.so.6
rpm -qa|grep glibc
查看是否已安装:
rpm -qa|grep -i mysql (-i 忽略大小写)
如已安装则查看安装路径:
ps -ef|grep mysql(具体见http://www.linuxidc.com/Linux/2012-08/69398.htm)
如已安装需先uninstall旧版本:
http://blog.csdn.net/superchanon/article/details/8546254/
groupadd mysql
useradd -r -g mysql mysql
mkdir /usr/local/mysql
tar -xvf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz -C /usr/local/mysql
cd /usr/local/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql
chown -R root:root ./
chown -R mysql:mysql data
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
cp support-files/mysql.server /etc/init.d/mysql
service mysql start
ps -ef|grep mysql (看到mysql服务说明启动成功)
./bin/mysqladmin -u root password '密码'
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
开启remote端口给主机访问
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
/etc/init.d/iptables save
service iptables restart
登录mysql设置主机访问权限
mysql -u root -p
use mysql
INSERT INTO `user` ( `Host` , `User` , `Password` , `Select_priv` , `Insert_priv` , `Update_priv` , `Delete_priv` , `Create_priv` , `Drop_priv` , `Reload_priv` , `Shutdown_priv` , `Process_priv` , `File_priv` , `Grant_priv` , `References_priv` , `Index_priv`
, `Alter_priv` , `Show_db_priv` , `Super_priv` , `Create_tmp_table_priv` , `Lock_tables_priv` , `Execute_priv` , `Repl_slave_priv` , `Repl_client_priv` , `ssl_type` , `ssl_cipher` , `x509_issuer` , `x509_subject` , `max_questions` , `max_updates` , `max_connections`
) VALUES ('%', 'root', PASSWORD( '123456' ) , 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', '', '', '', '', '0', '0', '0');
INSERT INTO `user` ( `Host` , `User` , `Password` , `Select_priv` , `Insert_priv` , `Update_priv` , `Delete_priv` , `Create_priv` , `Drop_priv` , `Reload_priv` , `Shutdown_priv` , `Process_priv` , `File_priv` , `Grant_priv` , `References_priv` , `Index_priv`
, `Alter_priv` , `Show_db_priv` , `Super_priv` , `Create_tmp_table_priv` , `Lock_tables_priv` , `Execute_priv` , `Repl_slave_priv` , `Repl_client_priv` , `ssl_type` , `ssl_cipher` , `x509_issuer` , `x509_subject` , `max_questions` , `max_updates` , `max_connections`
) VALUES ('%', 'guest', PASSWORD( '123456' ) , 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', '', '', '', '', '0', '0', '0');
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO ' root '@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
flush privileges;
select host,user,password from user;
exit
如需要绕过权限检验,可在配置文件(win: my.ini / linux: my.cnf)加上一句:
[mysqld]
skip-grant-tables
重启命令
-- windows:
net stop mysql (start)
-- linux:
service mysql stop (start)
参考:
http://jingyan.baidu.com/album/a378c9609eb652b3282830fd.html?picindex=2 http://www.jb51.net/article/31902.htm
--------------------------
RPM Installation
http://blog.csdn.net/superchanon/article/details/8546254/
In most cases, you only need to install the MySQL-server and MySQL-client packages to get a functional MySQL installation.
MySQL-devel-VERSION.i386.rpm The libraries and include files that are needed if you want to compile other MySQL clients, such as the Perl modules.
MySQL-shared-VERSION.i386.rpm This package contains the shared libraries (libmysqlclient.so*) that certain languages and applications need to dynamically load and use MySQL.
MySQL-shared-compat-VERSION.i386.rpm This package includes the shared libraries for both MySQL 3.23 and MySQL 4.0. Install this package instead of MySQL-shared if you have applications installed that are dynamically linked against MySQL 3.23 but you want to
upgrade to MySQL 4.0 without breaking the library dependencies.
MySQL-embedded-VERSION.i386.rpm The embedded MySQL server library (from MySQL 4.0).
从这里下载:http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz(更多不同版本下载见:http://mirrors.sohu.com/mysql/MySQL-5.6/)
先查看linux libc 版本是否一致:
ls -l /lib/libc.so.6
rpm -qa|grep glibc
查看是否已安装:
rpm -qa|grep -i mysql (-i 忽略大小写)
如已安装则查看安装路径:
ps -ef|grep mysql(具体见http://www.linuxidc.com/Linux/2012-08/69398.htm)
如已安装需先uninstall旧版本:
http://blog.csdn.net/superchanon/article/details/8546254/
groupadd mysql
useradd -r -g mysql mysql
mkdir /usr/local/mysql
tar -xvf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz -C /usr/local/mysql
cd /usr/local/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql
chown -R root:root ./
chown -R mysql:mysql data
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
cp support-files/mysql.server /etc/init.d/mysql
service mysql start
ps -ef|grep mysql (看到mysql服务说明启动成功)
./bin/mysqladmin -u root password '密码'
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
开启remote端口给主机访问
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
/etc/init.d/iptables save
service iptables restart
登录mysql设置主机访问权限
mysql -u root -p
use mysql
INSERT INTO `user` ( `Host` , `User` , `Password` , `Select_priv` , `Insert_priv` , `Update_priv` , `Delete_priv` , `Create_priv` , `Drop_priv` , `Reload_priv` , `Shutdown_priv` , `Process_priv` , `File_priv` , `Grant_priv` , `References_priv` , `Index_priv`
, `Alter_priv` , `Show_db_priv` , `Super_priv` , `Create_tmp_table_priv` , `Lock_tables_priv` , `Execute_priv` , `Repl_slave_priv` , `Repl_client_priv` , `ssl_type` , `ssl_cipher` , `x509_issuer` , `x509_subject` , `max_questions` , `max_updates` , `max_connections`
) VALUES ('%', 'root', PASSWORD( '123456' ) , 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', '', '', '', '', '0', '0', '0');
INSERT INTO `user` ( `Host` , `User` , `Password` , `Select_priv` , `Insert_priv` , `Update_priv` , `Delete_priv` , `Create_priv` , `Drop_priv` , `Reload_priv` , `Shutdown_priv` , `Process_priv` , `File_priv` , `Grant_priv` , `References_priv` , `Index_priv`
, `Alter_priv` , `Show_db_priv` , `Super_priv` , `Create_tmp_table_priv` , `Lock_tables_priv` , `Execute_priv` , `Repl_slave_priv` , `Repl_client_priv` , `ssl_type` , `ssl_cipher` , `x509_issuer` , `x509_subject` , `max_questions` , `max_updates` , `max_connections`
) VALUES ('%', 'guest', PASSWORD( '123456' ) , 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', '', '', '', '', '0', '0', '0');
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO ' root '@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
flush privileges;
select host,user,password from user;
exit
如需要绕过权限检验,可在配置文件(win: my.ini / linux: my.cnf)加上一句:
[mysqld]
skip-grant-tables
重启命令
-- windows:
net stop mysql (start)
-- linux:
service mysql stop (start)
参考:
http://jingyan.baidu.com/album/a378c9609eb652b3282830fd.html?picindex=2 http://www.jb51.net/article/31902.htm
--------------------------
RPM Installation
http://blog.csdn.net/superchanon/article/details/8546254/
In most cases, you only need to install the MySQL-server and MySQL-client packages to get a functional MySQL installation.
MySQL-devel-VERSION.i386.rpm The libraries and include files that are needed if you want to compile other MySQL clients, such as the Perl modules.
MySQL-shared-VERSION.i386.rpm This package contains the shared libraries (libmysqlclient.so*) that certain languages and applications need to dynamically load and use MySQL.
MySQL-shared-compat-VERSION.i386.rpm This package includes the shared libraries for both MySQL 3.23 and MySQL 4.0. Install this package instead of MySQL-shared if you have applications installed that are dynamically linked against MySQL 3.23 but you want to
upgrade to MySQL 4.0 without breaking the library dependencies.
MySQL-embedded-VERSION.i386.rpm The embedded MySQL server library (from MySQL 4.0).
相关文章推荐
- 30-linux学习总结
- Linux输入子系统
- centos7 部署cobbler
- 嵌入式 Linux进程含义知多少
- CentOS7修改主机名
- xargs用法详解
- Linux-Load Average解析
- linux安装dhcp服务器
- CentOS6服务管理之DNS-本地DNS服务器的搭建
- CentOS7将firewalld换成iptables
- linux用date更改时间还原
- Linux的内核态与用户态切换
- linux平常出现的一些故障
- linux sed 命令
- Linux GPIO 注册和应用
- CentOS6.6下bind搭建DNS服务器
- 29-学习linux其他知识补充
- 修改linux字符界面分辨率
- Linux中能ping通ip 不能ping通域名
- Centos默认的python2.6.6升级到python2.7.10全过程(包含setuptools/pip/django/yum设置)