Skip to content

Instantly share code, notes, and snippets.

@fagnersilva
Last active January 26, 2017 15:12
Show Gist options
  • Save fagnersilva/37c188d81c2b78710c51 to your computer and use it in GitHub Desktop.
Save fagnersilva/37c188d81c2b78710c51 to your computer and use it in GitHub Desktop.
Install MySQL
sudo apt-get install mysql-server
--------------------------------------------------------------------------------------------------------------------
Harden MySQL Server
sudo mysql_secure_installation
--------------------------------------------------------------------------------------------------------------------
Root Login
mysql -u root -p
--------------------------------------------------------------------------------------------------------------------
Create a New MySQL User and Database
create database testdb;
create user 'testuser'@'localhost' identified by 'password';
grant all on testdb.* to 'testuser';
grant all on testdb.* to 'testuser' identified by 'password';
--------------------------------------------------------------------------------------------------------------------
Create a Sample Table
mysql -u testuser -p
use testdb;
create table customers (customer_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name TEXT, last_name TEXT);
--------------------------------------------------------------------------------------------------------------------
external access permission
sudo vim /etc/mysql/my.cnf
bind-address = 0.0.0.0
$ iptables -F
$ iptables -L
$ service iptables save
--------------------------------------------------------------------------------------------------------------------
Reset the MySQL Root Password
sudo service mysql stop
sudo dpkg-reconfigure mysql-server
sudo service mysql start
@fagnersilva
Copy link
Author

Remover permissões de usuários
revoke all on banco.* from usuario;

@fagnersilva
Copy link
Author

fagnersilva commented Feb 17, 2016

GRANT ALL ON . TO 'root'@'%' IDENTIFIED BY '[senha]' WITH GRANT OPTION;
FLUSH PRIVILEGES;

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