1、确认mysql是否已安装,有下面的代码可知
2、卸载已安装的mysql,建议使用yum命令,因为yum命令可以自动删除与mysql相关的依赖;如果使用rpm命令,则还需要手动去删除和mysql相关的文件,比较麻烦
3、用whereis命令查找mysql相关的文件,因为步骤2用yum来卸载,所以mysql被清理得很干净;如果使用rpm将会很麻烦,有很多的文件需要手动清除
[root@cdh1 linuxidc]# whereis mysql mysql:
4、查看系统中的mysql安装包
5、选择mysql-server来安装
启动mysql服务
[root@cdh1 linuxidc]# chkconfig mysqld on
10、开启3306端口,并保存
[root@cdh1 linuxidc]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT [root@cdh1 linuxidc]# /etc/rc.d/init.d/iptables savemysql> use mysql;mysql> update user set password=password('123') where user='root';mysql> flush privileges;
[root@cdh1 linuxidc]# service mysqld restart
centos下pip install mysqlclient失败:
首先安装一下mysql-devel
yum install mysql-devel
如果已安装就忽略这一步
然后就可以直接安装mysqlclient了
pip install mysqlclient