当前位置:Gxlcms > 数据库问题 > 安装 MySQL 和 MySQLdb

安装 MySQL 和 MySQLdb

时间:2021-07-01 10:21:17 帮助过:36人阅读

-s /sbin/nologin -g mysql -M mysql cd /usr/local/src wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz tar -zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz mv mysql-5.6.36-linux-glibc2.5-x86_64 mysql && mv mysql /usr/local/ chown -R mysql.mysql /usr/local/mysql/ mkdir /usr/local/mysql/data cd /usr/local/mysql ./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql cp support-files/mysql.server /etc/init.d/mysqld /bin/cp support-files/my-default.cnf /etc/my.cnf chmod +x /etc/init.d/mysqld /etc/init.d/mysqld start chkconfig --add mysqld chkconfig mysqld on
mysqladmin -u root password ‘pzk123‘ # 根据实际自定义密码 echo
export PATH=/usr/local/mysql/bin:$PATH >> /etc/profile source /etc/profile 2>/dev/null

2、安装 MySQLdb

MySQLdb 是 Python 用于连接数据库的接口

yum install -y python-devel mysql-devel gcc unzip
cd /usr/local/src
wget --no-check-certificate https://pypi.python.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip#md5=654f75b302db6ed8dc5a898c625e030c
unzip MySQL-python-1.2.5.zip
cd MySQL-python-1.2.5
python setup.py build
python setup.py install
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
[root@localhost ~]# python
>>> import MySQLdb              # 如果能导入就说明安装成功

 

 

 

 

 

              

安装 MySQL 和 MySQLdb

标签:pytho   auto   pat   gcc   成功   build   https   setup.py   python   

人气教程排行