Skip to content

Instantly share code, notes, and snippets.

@yudapc
Last active August 29, 2015 14:19
Show Gist options
  • Save yudapc/d251c3e30b1915cef47c to your computer and use it in GitHub Desktop.
Save yudapc/d251c3e30b1915cef47c to your computer and use it in GitHub Desktop.
Mysql Ubuntu 14.04
CREATE USER 'userbaru'@'localhost' IDENTIFIED BY 'password_disini';
GRANT ALL PRIVILEGES ON namadatabase.* To 'userbaru'@'localhost' IDENTIFIED BY 'password_disini';
change password user:
use mysql;
update user set password=PASSWORD('your_new_password') where User='root';
Backup one database
mysqldump -u namauser -p namadatabase > namafile.sql
Backup one database and one table
mysqldump -u namauser -p namadatabase tablename > tablename.sql
Backup ALL:
mysqldump --lock-all-tables -u root -p --all-databases > dump.sql
Restore:
mysql -u root -p < dump.sql
Restart service:
sudo service mysql restart
Install:
sudo apt-get install phpmyadmin
sudo ln -s /usr/share/phpmyadmin /usr/share/nginx/html
sudo php5enmod mcrypt
sudo service php5-fpm restart
test to access: http://server_domain_or_IP/phpmyadmin
more scure:
1. generate password using this command:
$ openssl passwd
2. copy encripted password for example O5az.RSPzd.HE
3. create account:
$ sudo nano /etc/nginx/pma_pass
username:O5az.RSPzd.HE
4. configure in site-available:
location /phpmyadmin {
auth_basic "Admin Login";
auth_basic_user_file /etc/nginx/pma_pass;
}
5. Restart nginx:
$ sudo service nginx restart
6. Try to access: http://server_domain_or_IP/phpmyadmin
if there is login form your configuration is true
Logout from phpmyadmin:
/index.php?old_usr=whateve
sudo deluser mysql
sudo delgroup mysql
sudo service mysql stop #or mysqld
sudo killall -9 mysql
sudo killall -9 mysqld
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql
sudo apt-get purge mysql-server-core-5.5
sudo apt-get purge mysql-client-core-5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment