mysql 忘记密码重置
1. 停止 MySQL 服务
$ cd /usr/local/mysql/bin/
$ mysql.server stop
2.进入安全模式
$ cd /usr/local/mysql/bin/
$ sudo ./mysqld_safe --skip-grant-tables
3.新开一个终端,进入 MySQL
输入mysql命令直接进入
$ cd /usr/local/mysql/bin/
$ mysql
> use mysql
> flush privileges;
> set password for 'root'@'localhost'='***'
修改完成。
4.重启
cd /usr/local/mysql/bin/
mysql.server start
mysql 安装 MYSQL-python
正常情况
sudo pip install MYSQL-python
出错情况
Collecting MySQL-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/d1/1lnf846x6p119488dvhnqj740000gn/T/pip-build-b16vZo/MySQL-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 53, in get_config
libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
File "setup_posix.py", line 8, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range
谷歌上有
export PATH=$PATH:/usr/local/mysql/bin/
据说可以解决,但我这边一直解决不了
最终解决方法:
1.卸载安装的mysql
$ find . -name "*mysql*"
$ 删除那些文件
2.重新安装brew
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
3.再装MySQL
$ brew install mysql
4.装x-code
$ xcode-select --install
5.success
$ pip install MySQL-python
一些常用命令
1. 查看sqlserver的端口号
mysql> show global variables like 'port';
2.查看SQL的执行计划
explain 查询语句;