CoreBSD Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

coreartikel:contekan.mysql [2005/10/19 01:55] – created bangcoreartikel:contekan.mysql [2025/10/25 17:09] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== MYSQL Frequently Annoying Questions ======
  
 +Setting password root mysql untuk pertama kali
 +
 +<code>
 +$mysqladmin -u root password ‘password baru’
 +</code>
 +
 +Menambah user di mysql
 +
 +<code>
 +$mysql -u root -p mysql mysql>insert into user (host, user, password) values (’%',’hengky’, password(’passwordnya’));
 +</code>
 +
 +Buat database baru 
 +
 +<code>
 +$mysql -u root -p mysql
 +mysql>create database hky; grant all privileges on hky.* to hengky; flush privileges;
 +</code>
 +
 +Ganti password dan kasi grant ke satu orang user(hengky) 
 +
 +<code>
 +$mysql -u root -p mysql 
 +mysql>update user set password=password(’passwordbaru’) where user=’hengky’ ;flush privileges; 
 +</code>
 +
 +atau 
 +
 +<code>
 +mysql>set password for hengky=password(’passwordbaru’);
 +</code>
 +
 +Load file yang berisi skema database (sql syntax) 
 +
 +<code>
 +$mysql -u hengky -p namadatabase < filenya.sql
 +</code>
 +
 +Backup database 
 +
 +<code>
 +$mysqldump -A -u root -p > backup.sql
 +</code>
 +
 +==== Bagaimana caranya mereset password root di mysql ? ====
 +
 +
 +    * Matikan daemon mysql anda, kemudian start lagi dengan menambahkan argumen --skip-grant-tables (misalnya seperti ini : /usr/local/mysql/bin/safe_mysqld --skip-grant-tables &)
 +    * Kemudian masuk ke database mysql dan update password root yang baru, misalnya begini :
 +
 +<code>
 +$ mysql -u root mysql
 +Welcome to the MySQL monitor. Commands end with ; or \g.
 +Your MySQL connection id is 1564 to server version: 3.23.39-log
 +
 +Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 +
 +mysql> update user set password=password("rahasiadeh") where user='root';
 +mysql> flush privileges;
 +mysql> exit
 +</code>
 +
 +  *Restart mysql anda seperti biasanya