ubuntu安装mysql后的配置

1,备份 /etc/mysql/my.cnf

sudo cp /etc/mysql/my.cnf /etc/mysql/my.cnf.bak


2.编辑my.cnf

sudo vi /etc/mysql/my.cnf

大约47行  

       #bind-address       = 127.0.0.1

加#注释掉  否则不能远程登录  

[mysqld]里添加一行

     character_set-server=utf8    (这里特别注意,老版本的是设置 default-character-set=utf8 然后服务无法启动)

设置mysql默认编码方式,默认的latin1不支持中文


这两项改完后   sudo /etc/init.d/mysql restart  重启服务,登录mysql    通过 status查看编码是否修改成功。


3.取消开机启动

由于不是每次开机都需要用到mysql,服务自启动浪费资源,改为手动管理mysql服务。


zhh@itant:/etc/init.d$ sudo service mysql stop
mysql stop/waiting
zhh@itant:/etc/init.d$ sudo update-rc.d -f mysql remove
 Removing any system startup links for /etc/init.d/mysql ...
zhh@itant:/etc/init.d$ sudo service mysql start
mysql start/running, process 5186
zhh@itant:/etc/init.d$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 5.5.29-0ubuntu0.12.04.2 (Ubuntu)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye
zhh@itant:/etc/init.d$ 

4.安装python-mysql

下载mysql-python    进入mysql-python目录,python install.py install 安装

提示 mysql_config not found,执行 sudo apt-get install libmysqld-dev  然后 sudo find /  -name mysql_config 将查到的路径 编辑到 site.cfg中。

提示 _mysql.c:29:20: 致命错误: Python.h:没有那个文件或目录 ,执行 sudo apt-get install python-dev 

最后执行安装命令

sudo python setup.py build

sudo python setup.py install 

测试: python->import MySQLdb



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值