linux上安装mysql
安装mysql:
- 安装MYSQL
当前centos7上没有最新版本5.6.21的Mysql yum原,所以不能用如下的方式安装yum install MySQL-server
yum install MySQL-devel -
下载最新的rpm 安装包。
MySQL-client-5.6.21-1.el6.x86_64.rpm
MySQL-server-5.6.21-1.el6.x86_64.rpm
MySQL-devel-5.6.21-1.el6.x86_64.rpm -
移除可能冲突的MariaDB
sudo yum remove MariaDB-server-5.5.53-1.el7.centos.x86_64
sudo yum remove MariaDB-common-5.5.53-1.el7.centos.x86_64 -
安装:
sudo rpm -ivh MySQL-server-5.6.21-1.el6.x86_64.rpm
sudo rpm -ivh MySQL-client-5.6.21-1.el6.x86_64.rpm
sudo rpm -ivh MySQL-devel-5.6.21-1.el6.x86_64.rpm -
启动mysql
sudo service mysql restart -
新增用户 mysqladmin -u root password 123456
- 修改本地数据库端口号. vi /etc/my.cnf 加一行port = 3306
- 远程登录:
本地登录数据库 mysql -u root -p123456
新建远程登录账号
mysql> CREATE USER 'root'@'你的远程机器IP' IDENTIFIED BY '123456';
'root'@'远程机器IP'
mysql> GRANT ALL PRIVILEGES ON *.* TO-> WITH GRANT OPTION;
mysql> CREATE USER 'root'@'%' IDENTIFIED BY '123456';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'
-> WITH GRANT OPTION;
1。mysql -h localhost -u root -p
http://stackoverflow.com/questions/1559955/host-xxx-xx-xxx-xxx-is-not-allowed-to-connect-to-this-mysql-server
重启服务就Ok了
安装 phpMyadmin来管理数据库:
# vim /etc/httpd/conf/httpd.conf
Add the following lines here:
<Directory "/usr/share/phpmyadmin">
Order allow,deny
Allow from all
</Directory>
最后还是不行
First edit the file /etc/httpd/conf.d/phpMyAdmin.conf and add the additional line to the directory settings:
<Directory /usr/share/phpMyAdmin/>
order deny,allow
deny from all
allow from 127.0.0.1
allow from 192.168.1.0/15
</Directory>
If you wanted to allow access to everybody then you could just change it to:
<Directory /usr/share/phpMyAdmin/>
order allow,deny
allow from all
</Directory>
解决了上一部的Forbiden错误进入登陆界面:
#1862 Cannot log in to the MySQL server
如果有上面的错误,证明数据库密码过期,需要重置。 参照安装数据库的最后一步
新用户名 远程连接:
至此其实可以用PHPMyadmin来管理你的数据库了,包括查询等,但是可以装一个下面的客户端,远程连接上去。更好
本地安装 mysql workbench
1. 下载mysqlworkbench : http://dev.mysql.com/downloads/workbench/
2. 下在完成以后 shell 到这个rpm的路径。 执行: sudo yum install mysqlworkbench.rpm 在安装过程中发现错误
获取 GPG 密钥失败:[Errno 14] curl#37 - "Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6"
解决办法,从rpm上下载这个缺失的文件
rpm --import http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
还有可能出现一些依赖的lib 版本不正确的情况,如
错误:软件包:mysql-workbench-community-6.3.6-1.el7.x86_64 (/mysql-workbench-community-6.3.6-1.el7.x86_64)
需要:python-paramiko >= 1.15.1
已安装: python-paramiko-1.12.4-1.el7.centos.noarch (@extras)
python-paramiko = 1.12.4-1.el7.centos
解决办法: 当前的centos中存在着依赖,他的版本低于需要的。
yum remove python-paramiko-1.12.4-1.el7.centos.noarch
网上下载正确的rpm 本地安装一下就行了
启动mysqlworkbench的时候出现错误
[ygshen@localhost Software]$ mysql-workbench
/usr/libexec/mysql-workbench/mysql-workbench-bin: error while loading shared libraries: libtinyxml.so.0: cannot open shared object file: No such file or directory
原因是缺少依赖包,按理说在rpm install的过程中应该安装了 但是没有需要手动撞一下
sudo yum install libtiny (tab以下 )会发现所有的版本
[ygshen@localhost mysql-workbench]$ sudo yum install tiny
tinyca2.noarch tinyxml2-devel.i686 tinyxml-devel.i686
tinyfugue.x86_64 tinyxml2-devel.x86_64 tinyxml-devel.x86_64
tinymce.noarch tinyxml2.i686 tinyxml.i686
tinyproxy.x86_64 tinyxml2.x86_64
安装以下就可以了
至此安装完成,启动 >shell: mysql-workbench 就启动gui了