Skip to content

Instantly share code, notes, and snippets.

@aquasmit
Last active November 28, 2016 05:19
Show Gist options
  • Save aquasmit/0b382ef53a796b99c32016bbc36bf476 to your computer and use it in GitHub Desktop.
Save aquasmit/0b382ef53a796b99c32016bbc36bf476 to your computer and use it in GitHub Desktop.
MySQL essential queries

Get list of mysql users

$ SELECT User FROM mysql.user;

###Enable remote access to mysql For MySQL < 5.7

$ sudo nano /etc/mysql/my.cnf

For MySQL 5.7

$ sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

In this file, locate "bind-address" directive, and change its value from 127.0.0.1 to 0.0.0.0

Save this file & restart mysql

sudo service mysql restart

###Create new mysql user & give full access

````$ mysql -u root -p``` #enter root password

$ CREATE USER 'demo'@'%' IDENTIFIED BY 'demo123';

$ GRANT ALL PRIVILEGES ON *.* TO 'demo'@'%' IDENTIFIED BY 'demo123';

$ FLUSH PRIVILEGES;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment