I can't start mysql server after modifying data folder - Mac OS - mysql

I used the following command on terminal (Mac 10.11.6) to copy database (map) from backup disk (Time Machine) from old mysql folder I had.
sudo cp -R '/Volumes/Time Machine Backups/Backups.backupdb/MacBook Pro/2016-09-26-212804/Macintosh HD/usr/local/mysql/data/map' /usr/local/mysql/data/map
It did copy the database but I couldn't start mysql server again .
I used this command :
sudo /usr/local/mysql/support-files/mysql.server start
I get this error :
ERROR! The server quit without updating PID file (/usr/local/mysql/data/computerName-MBP.pid).

Related

Recover MySQL /var/lib/mysql after update

I did an update from Mysql 5.5 to 8.0 in a Centos 6 server without dumping the databases to a .sql file, I just copied the /var/lib/mysql directory to another location.
Now if I try to load mysqld service it crashes.
Being naive I deleted all the content of /var/lib/mysql and installed the service again, now it runs but now I do not know how to manually import the DB files to the directory (copy & paste of the folder does not work) in order to do a check of the DB and/or repair it.
rysnc should likely already be installed, but if it isn't you would:
sudo yum install rsync
Then
#make sure mysql isn't running
sudo service mysqld stop
#double check that there is no MySQL PID running
sudo ps aux | grep mysql
#move the new MySQL 8.0 data files out of the way
sudo mv /var/lib/mysql /var/lib/mysql.bak
#copy the original data files back to /var/lib/mysql
#note that the trailing / is required for both paths
sudo rsync -av /path/to/original/mysql/db/files/ /var/lib/mysql/
#change user and group ownership to mysql
sudo chown -R mysql:mysql /var/lib/mysql
#start MySQL
sudo service mysqld start
#run mysql_upgrade, replace {usernamehere} with the actual username
sudo mysql_upgrade -u {usernamehere} -p
Update:
You will need to downgrade the binaries to 5.5. Take a backup of each database once MySQL is running again and then upgrade in the following order:
5.6
5.7
8.0
You will need to run mysql_upgrade after each upgrade.

Cannot find PID file after reinstall of mysql

I was getting an error that server quit without updating pid file. So I thought I would uninstall it and install it again.
I had installed it with homebrew last time so I did:
brew uninstall mysql
and to install it I did:
brew install mysql
Even after this however, I am still getting the same error.
$ mysql.server start
Starting MySQL
. ERROR! The server quit without updating PID file (/usr/local/var/mysql/Tirths-MBP.fios-router.home.pid).
If this mysql like a linux binaries; Try to regen PID with mysqld_safe as :
stop server
bin>$./mysql.server stop
regen PID file :
bin>$./mysqld_safe -u youruser&
then try to start mysql as :
bin>$./mysql.server start
p.s.
...and do you have etc/my.cnf file gen-ed ? It would be more helpful you to provide logs;
Hope this helps; Report your results please;

FreeBSD MySQL error after installation

I am on FreeBSD 10.2 32 bit and installed the newest version of mysql with the following command:
pkg install mysql57-server-5.7.12
Now, when I try to start mysql:
service mysql-server start
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql
I am getting this error. I hope you can help me.
Check your /var/db/mysql folder, if it contains files, make a backup and delete dir content:
rm -rf /var/db/mysql/*
Then do a data directory initialization:
/usr/local/libexec/mysqld --initialize --user=mysql
You should get a new temporary password, write it down, then start mysql-server
service mysql-server start
After mysql starts, secure the installation via:
/usr/local/bin/mysql_secure_installation
Open /etc/rc.conf and append or modify this line :
mysql_enable="YES"
Save the file, close it and retry to start the server.

ERROR! The server quit without updating PID file (/usr/local/var/mysql/Bridge.local.pid)

I was not able to run mysql so i deleted it and reinstalled it using home brew .Now when i run the mysql.server start command i get the following error
ERROR! The server quit without updating PID file (/usr/local/var/mysql/Bridge.local.pid).
Here are the contents of my my.conf file in usr/local/Cellar/mysql/5.7.10/mysql-test/include/default_my.cnf where homebrew has installed mysql
# Use default setting for mysqld processes
!include default_mysqld.cnf
!include default_client.cnf
[mysqld.1]
# Run the master.sh script before starting this process
#!run-master-sh
log-bin= master-bin
# Run tests with the performance schema instrumentation
loose-enable-performance-schema
[mysqlbinlog]
disable-force-if-open
[ENV]
MASTER_MYPORT= #mysqld.1.port
MASTER_MYSOCK= #mysqld.1.socket
~
Maybe mysql does not have permission to the folder where the pid file is located in.
Solution working for my case:
Check your error log at /usr/local/var/mysql/Bridge.local.err
If there is something like this in the log: ...[Note] Unable to delete pid file: Permission denied..., which means mysql does not have the permission to
your mysql folder
Use the following command in terminal to grant the permission: sudo chown -R mysql /usr/local/var/mysql/

Restore Databases from Phpymyadmin

I test Drupal websites on my site locally on Mac using Phpmyadmin.
I recently had to to do a clean reinstall of my Mac. I have a full back up of my hardrive, but I'm not sure where to locate the databases in the back up and how to restore them.
Where does Phpmyadmin store the databases?
/usr/local/mysql/data
try it here
phpMyAdmin does not write any database files. It is a php client application which accesses a MySQL server.
On OSX the MySQL server creates its data files in /usr/local/mysql/data as far as I know.
1. Stop your MySQL server
sudo /usr/local/bin/mysql.server stop
2. Remove new data files
sudo mv /usr/local/mysql/data /usr/local/mysql/data.new
3. Copy old data files from your backup and fix prrmissions
sudo chown -R _mysql:wheel /usr/local/mysql/data
4. Start your server again
sudo /usr/local/bin/mysql.server start
5. Check and optimize databases
sudo /usr/local/mysql/bin/mysqlcheck --all-databases
Now phpMyAdmin will show all old databases