Add a second instance of MySQL on existing MySQL Server


//////my sql installation

mysql_install_db –user=mysql –basedir=/usr –datadir=/var/lib/mysql2 –defaults-file=/etc/mysql/my_server2.cnf
mysqld_safe –defaults-file=/etc/mysql/my_server2.cnf –user=mysql &

netstat -tanp |grep 3307
mysql -u root -p -h 127.0.0.1 -P 3307

//allow remote access
GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;
FLUSH PRIVILEGES;

//update password
update user set password=PASSWORD(“mynewpassword”) where User=’root’;
FLUSH PRIVILEGES;

//my sql armour
https://ubuntuforums.org/showthread.php?t=782224

vim /etc/apparmor.d/usr.sbin.mysqld
ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/usr.sbin.mysqld
/etc/init.d/apparmor restart

//disable armour
https://askubuntu.com/questions/175820/mysql-doesnt-update-due-to-error-in-apparmor-profile/175852
ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/usr.sbin.mysqld

///test connection php

How To Fix “Error Establishing A Database Connection” In WordPress

<?php
$test Connection = mysql_connect(‘localhost’, ‘root’, ‘password’);
if (!$testConnection) {
die(‘Error: ‘ . mysql_error());
}
echo ‘Database connection working!’;
mysql_close($testConnection);
?>

Leave a comment

Your email address will not be published. Required fields are marked *