Follow Below Steps:-
Step (1): Create a new MySQL data directory.
mkdir -p /var/lib/mysql2
Step 2: Give permission and ownership .Now we are taking ownership and permission reference from original /var/lib/mysql data directory
chmod --reference /var/lib/mysql /var/lib/mysql2 chown --reference /var/lib/mysql /var/lib/mysql2
Step 3: Now create a new my1.cnf file and paste the below given contents. We will run the new mysql instance in port no. 3307.
Copy the my.cnf file and make it blank
cp -p /etc/my.cnf /etc/my1.cnf
Now edit with vi editor.
vi /etc/my1.cnf
Edit in [mysqld] and [mysqld_safe] section.
[mysqld] datadir=/var/lib/mysql2 socket=/var/lib/mysql/mysql2.sock port=3307 [mysqld_safe] log-error=/var/log/mysqld2.log pid-file=/var/run/mysqld/mysqld2.pid
Step 4: Now install the database in the new mysql data directory
mysql_install_db --user=mysql --datadir=/var/lib/mysql2
Step 5: Now the new instance is ready.Now start and stop with the below commands
To start new mysql instance,use below given command
mysqld_safe --defaults-file=/etc/my1.cnf &
Now check the port no. 3337 is listening or not
netstat -tanp |grep 3307
To connect new mysql instance
Syntax: mysql -u username -p -h 127.0.0.1 -P port-no
Now set root password
Now set root password
mysql > use mysql; mysql > update user set password=PASSWORD("password") where User='root'; mysql > flush privileges; mysql > exit
To stop new mysql instance use below given command
mysqladmin -S /var/lib/mysql/mysql2.sock shutdown -p
0 comments:
Post a Comment