Linux系统上安装MySQL
安装MySQL
卸载自带mysql
查询mysql的安装情况,可以直接使用了
rpm -qa | grep-imysql –-color
卸载原生的MySQL
rpm -e --nodeps mysql-libs-5.1.71-1.el6.i686
上传mysql到Linux
CRT远程连接软件中:alt+p 拖拽上传即可
安装依赖(准备阶段已经安装过了)
yum -y install libaio.so.1 libgcc_s.so.1 libstdc++.so.6
yum update libstdc++-4.4.7-4.el6.x86_64
安装mysql的服务端
安装服务端
rpm -ivh MySQL-server-5.5.49-1.linux2.6.i386.rpm
默认安装在usr目录中
[root@yejing ~]# rpm -ivh MySQL-server-5.1.73-1.glibc23.i386.rpm
Preparing... ###########################################[100%]
1:MySQL-server ########################################### [100%]PLEASE REMEMBERTO SET A PASSWORD FOR THE MySQL root USER!To do so, start the server, thenissue the following commands:/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h yejing password 'new-password'Alternatively you can run:/usr/bin/mysql_secure_installation
which will also give you theoption ofremoving the test
databasesand anonymous user created by default. This isstrongly recommendedforproduction servers.
See the manualformore instructions.
Please reportany problems with the /usr/bin/mysqlbug script!
Starting MySQL....[确定]
[root@yejing ~]#
安装mysql的客户端
rpm -ivh MySQL-client-5.5.49-1.linux2.6.i386.rpm
[root@yejing ~]# rpm -ivh MySQL-client-5.1.73-1.glibc23.i386.rpm
Preparing... ###########################################[100%]
1:MySQL-client ########################################### [100%]
[root@yejing ~]#
启动mysql的服务
启动MySQL服务
service mysql start
设置mysql初始密码并登陆MySQL
/usr/bin/mysqladmin -u root password '123456'
设置开机自动启动mysql
加入到系统服务:
chkconfig --add mysql
自动启动(关闭):
chkconfig mysql on/off
开启远程服务
登录mysql:
//赋予root用户所有权限,远程登录密码是123456
grant all privileges on *.* to 'root' @'%' identified by '123456';
flush privileges;//刷新权限
设置Linux的防火墙
Linux防火墙默认拦截3306端口
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT//将3306端口进行防火墙的开启
/etc/rc.d/init.d/iptables save//防火墙重新刷新保存
[root@yejing ~]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
[root@yejing ~]# /etc/rc.d/init.d/iptables saveiptables:将防火墙规则保存到/etc/sysconfig/iptables:[确定]