Skip to content

MySQL

MySQL#


Set up MySQL#

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
- change bind to 0.0.0.0
sudo systemctl restart mysql
sudo ufw allow from remote_ip_address to any port 3306
sudo mysql -u root
CREATE USER 'username'@'host' IDENTIFIED BY authentication_plugin BY 'password';
GRANT PRIVILEGE ON database.table TO 'username'@'host';
FLUSH PRIVILEGES;
sudo systemctl restart mysql




MySQL in Linux#

  • After log in
  • Show content of a table
    SELECT * FROM Wordpress.wp_options;

  • Select Database
    USE Wordpress;

-Update data of wordpress
UPDATE wp_options SET option_value = replace(option_value, 'https://web.com' , 'http://web.com');

  • Delete Database
    DROP DATABASE <name>

  • Show Database
    Show tables;

Use MySQL Workbench#

  1. Create user for that specific PC's User to use workbench on
    CREATE USER 'username'@ip.of.that.pc' IDENTIFIED BY 'password';

  2. Grant all privileges
    GRANT ALL PRIVILEGES ON *.* TO 'username'@'ip.of.that.pc';

  3. Flush Privilleges
    FLUSH PRIVILEGES;

  4. Exit and Restart MySQL
    sudo systemctl restart mysql