Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

Monday, August 17, 2015

How to reset your first installed mysql database password?

  • For newly installed mysql database, the default database password is empty
  • In order to reset the password, type in the "mysql" command at terminal window. 
  • Type in the command below to reset the password
mysql > UPDATE mysql.user SET password=password('password') WHERE user='root' AND host='localhost';
  • If the error message as shown below is displayed
ERROR 1227 (42000): Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
  • Add the 2 parameter to my.cnf file
[mysqld]
skip-grant-tables
skip-networking
  • Restart mysql services
  • Type in command "mysql" to login into mysql, rerun the command below, you should be able to reset your root password
mysql > UPDATE mysql.user SET password=password('password') WHERE user='root' AND host='localhost';
mysql > FLUSH PRIVILEGES; 

Friday, December 13, 2013

How to import MySql dump with big blob field?

Error message "Error Code: 2006 - MySQL server has gone away" is prompted when trying to import MySql database dump consists of big blob field value into MySql database.

Below are the steps to resolve this issue
1. Edit max_allowed_packet parameter in my.ini
max_allowed_packet = 524288000
2. Restart MySql database server
Assume the parameters below represent 
Database user id, for example, 'root' : [DB_USER_LOGIN] 
Database dump file : [DB_DUMP_FILE] 
Database name : [DATABASE_NAME]

3. Connect to database
mysql -u[DB_USER_LOGIN]
4. Use the new database that created for importing
use [DATABASE_NAME]
5. Import the data from database dump into newly created database.
\. [DB_DUMP_FILE]

Tuesday, October 15, 2013

How to migrate MySql data files to other folder/drive?

Let's say you have installed an application that make used of the mysql database and you have completed the installation in a particular folder/drive. Now, you wish to migrate the data storing location to other folder/drive. In order to migrate MySql data files location, below are the details steps :-

Environment
OS: Window 7 Enterprise
MySQL: MySQL version 5.6.12

Assumption
MySQL home directory : [MYSQL_HOME]
MySQL new data files directory : [NEW_DATA_FOLDER]

1. Shutdown MySQL database
2. Copy the "data" folder that normally located at [MYSQL_HOME]\data to new data files directory, [MY_NEW_DATA], for example, "d:\data".
3. Open my.ini that located at [MYSQL_HOME]\my.ini
4. Edit the my.ini by changing the parameter as describe below:
datadir=[NEW_DATA_FOLDER]
5. Restart the MySql database server, that's it!

Thursday, February 21, 2013

How to set firewall rule in Window 2008 to allow remote server to connect to MySQL on port 3306?

I have 2 servers, 1 application server and the other 1 is database server. My database server is using MySql which is listening on port 3306. To enable my application server to connect to database server to port 3306, I have tried many effort in setting the Inbound rules and Outbound rules on Window 2008 firewall which I described in my previous post. Anyway, no luck in following the network engineer advice and now is my doubt on his ability...

1 magic tips which I search through the internet and it is great and it just works perfectly
netsh advfirewall firewall add rule name="MySQL Server" action=allow protocol=TCP dir=in localport=3306

Tuesday, January 22, 2013

How to grant access to remote server to connect to MySQL server?

Normally, if your application server and database server are sitting in 2 different server, you are unable to connect from application server to the database server without granting access rights in the mysql database. To grant the access rights, below are the command which you can cut and paste into your mysql browser and run.

GRANT ALL PRIVILEGES ON *.* TO username@address IDENTIFIED BY “password”;
flush privileges;

username = [USER ID] in the application server
address = [IP Address of the remote machine]
password = [PASSWORD of the USER ID]

Once run the script, voila! you get the rights to connect to the database server from application server.

Friday, September 21, 2012

How to setup mySQL SSH Tunnel using Putty?

1. Configure your SSH server configuration as shown in the screen below:


2. Click on Connection -> SSH -> Tunnels, enter 

Source Port: 3307
Destination: localhost:3306

3. Once "Add" button is clicked, the screen as shown below is displayed. Click "Open" button to connect to your server, enter your SSH login name and password.



4. Once connected, open your mysql browser to connect to localhost with port 3307.





Tada! Here you get into your mysql database through SSH tunnel.