osx中安装mysql数据库

来源:互联网 发布:gmm 算法训练 编辑:程序博客网 时间:2024/06/08 08:20

1、安装mysql

brew install mysql

2、启动或关闭mysql

brew services start mysql(启动)或 mysql.server start
brew services stop mysql(停止)

3、mysql相关权限配置

3.1、执行:/usr/local/Cellar/mysql/5.7.14/bin/mysql_secure_installation ,进行一些初始化配置。

Securing the MySQL server deployment.Connecting to MySQL using a blank password.VALIDATE PASSWORD PLUGIN can be used to test passwordsand improve security. It checks the strength of passwordand allows the users to set only those passwords which aresecure enough. Would you like to setup VALIDATE PASSWORD plugin?Press y|Y for Yes, any other key for No: yThere are three levels of password validation policy:LOW    Length >= 8MEDIUM Length >= 8, numeric, mixed case, and special charactersSTRONG Length >= 8, numeric, mixed case, special characters and dictionary                  filePlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0Please set the password for root here.New password: Re-enter new password: Estimated strength of the password: 50 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : yBy default, a MySQL installation has an anonymous user,allowing anyone to log into MySQL without having to havea user account created for them. This is intended only fortesting, and to make the installation go a bit smoother.You should remove them before moving into a productionenvironment.Remove anonymous users? (Press y|Y for Yes, any other key for No) : n ... skipping.Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess atthe root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : ySuccess.By default, MySQL comes with a database named 'test' thatanyone can access. This is also intended only for testing,and should be removed before moving into a productionenvironment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database...Success. - Removing privileges on test database...Success.Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : ySuccess.All done! 
3.2、创建数据库
mysql -u root -p 以root权限进入create database test; 创建数据库语句drop database test; 删除数据库语句show databases;显示数据库create user 'yourusername'@'127.0.0.1/localhost' identified by 'yourpassword’; 创建用户GRANT ALL ON test.* TO '<span style="font-family: -webkit-standard;">yourusername</span>'@‘127.0.0.1/localhost' IDENTIFIED BY 'yourpassword’; 给用户授权select user,host from mysql.user; 查询用户及端口select user(),current_user(); 查询用户mysql -u youusername -p 以用户权限进入


参考:python使用mysql数据库

0 0
原创粉丝点击