I am trying to install MySQL 5.6.17 on Ubuntu Linux and I am having difficulties doing so. I opened the MySQL Reference and opened "Installing MySQL on Unix/Linux Using Generic Binaries". I followed the following step:
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &
//Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
After that when I try to start MySQL using /etc/init.d/mysql.server start I get the following error:
Couldn't find MySQL server (/usr/bin/mysqld_safe)
I looked in /usr/bin and I found mysqld_safe. Any suggestions on how to fix that problem. Please reply with a detailed solution.
Thank You
It seems you have installed Mysql in "/usr/local" and init script is looking for binaries in "/usr"
Change the "basedir" in /etc/init.d/mysql.server to :
basedir=/usr/local
The fact that you found /usr/bin/mysqld_safe suggests that MySQL in some shape or form was preinstalled on your OS. This can cause some confusion, in particular due to location of config files.
So for instance, on some versions of Ubuntu, the packages mysql-common is pre-installed, which means you might have an /etc/mysql/my.conf file with some defaults in it. When you install from the tar file to /usr/local, follow the INSTALL-BINARIES (or equivalent) instructions, and try to start /etc/init.d/mysql.server start you might get errors as the one you report ("Couldn't find MySQL server (/usr/bin/mysqld_safe)"), because the default configuration in /etc/init.d/mysql.server and any /etc/my.cnf that you created (optional step during install) is getting over-ridden by a setting in the OS installed /etc/mysql/my.conf. Note that this might happen even if you change the values in /etc/init.d/mysql.server and/or /etc/my.cnf.
One way out is to merge /etc/my.cnf and /etc/mysql/my.cnf into a single file at one of these locations, with the correct defaults that you wish to use.
Related
While installing MySQL 5.7 on centos7, I am struggling with the data directory initialization step:
bin/mysqld --initialize --user=mysql
I am getting an error as
bin/mysqld:Error on realpath on 'var\lib\mysql-files'
Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MYSQL server.Supplied value : /var/lib/mysql-files
.
Please suggest.
As described in the MySQL documentation,
/var/lib/mysql-files is the (default) directory where mysql allows import/export operations to work only with files, and the directory MUST exist.
You could try either:
Make sure the directory exists and give access to mysql
sudo mkdir -p /var/lib/mysql-files
sudo chown -R mysql:mysql /var/lib/mysql-files
sudo chmod -R 770 /var/lib/mysql-files
Or:
Disable this option from my.cnf
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.
Is it possible to upgrade the MAMP MySQL library to 5.7?
I am currently running 5.6 (which I upgraded to using MAMP’s upgrade script
)
Or would I need to install MySQL natively on my system? (macOS 10.11 El Capitan)
If someone could point me in the right direction… Thanks!
Upgrade MAMP to Mysql 5.7
#!/bin/sh
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.10-osx10.10-x86_64.tar.gz
tar xfvz mysql-5.7*
echo "stopping mamp"
sudo /Applications/MAMP/bin/stop.sh
sudo killall httpd mysqld
echo "creating backup"
sudo rsync -arv --progress /Applications/MAMP ~/Desktop/MAMP-Backup
echo "copy bin"
sudo rsync -arv --progress mysql-5.7.*/bin/* /Applications/MAMP/Library/bin/ --exclude=mysqld_multi --exclude=mysqld_safe
echo "copy share"
sudo rsync -arv --progress mysql-5.7.*/share/* /Applications/MAMP/Library/share/
echo "fixing access (workaround)"
sudo chmod -R o+rw /Applications/MAMP/db/mysql/
sudo chmod -R o+rw /Applications/MAMP/tmp/mysql/
sudo chmod -R o+rw "/Library/Application Support/appsolute/MAMP PRO/db/mysql/"
echo "starting mamp"
sudo /Applications/MAMP/bin/start.sh
echo "migrate to new version"
/Applications/MAMP/Library/bin/mysql_upgrade -u root --password=root -h 127.0.0.1
UPDATE: Version 5.0 of MAMP now includes MySQL 5.7 already in the installer! Just upgrade your core MAMP setup and you are set to go with MySQL instead of having to jump through technical hoops like this.
Leaving answer below as a reference for anyone who needs it.
While I have read this answers and comments here—as well as some similar linked tutorials on GitHub and such—there were a few things that confused me in some of the tutorials. Such as instructions to set chmod -O o+rw and even a comment about creating a symbolic link to /tmp/mysql.sock; why do that when MAMP out of the box should be self contained and not require such changes? So here are the instructions I have put together based on my experience getting MySQL upgraded for MAMP 4.4.1 on mac OS 10.3.4 (High Sierra).
First, get a copy of the macOS binaries for MySQL 5.7; note that as of me posting this answer MySQL 5.7.22 is the current version so adjust this URL to whatever new version you might want to use:
curl -OL https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-macos10.13-x86_64.tar.gz
Decompress it like this:
tar xfvz mysql-5.7*
Copy the bin/ and share/ stuff into MAMP via Rsync like this:
sudo rsync -arv --progress mysql-5.7.*/bin/* /Applications/MAMP/Library/bin/ --exclude=mysqld_multi --exclude=mysqld_safe
sudo rsync -arv --progress mysql-5.7.*/share/* /Applications/MAMP/Library/share/
Copy your existing MySQL 5.6 database directory like this; just note that the mysql56 directory is temporarily needed during the upgrade but can be discarded after the rest of the MySQL 5.7 upgrade is done:
sudo cp -r /Applications/MAMP/db/mysql56 /Applications/MAMP/db/mysql57
Once that is done, get rid of MySQL database specific binaries like this for upgrade:
sudo rm -rf /Applications/MAMP/db/mysql57/mysql/innodb_*
sudo rm -rf /Applications/MAMP/db/mysql57/mysql/slave_*
And instead of changing permissions to o+rw just change the owner of the DB directory to your current user; this matches how MAMP installs this stuff:
sudo chown -R ${USER}:admin /Applications/MAMP/db/mysql57
Now run this Sed command to adjust the mysqld_safe script to point to the new MySQL 5.7 path; you could probably just open this file up in a text editor and change all instances of mysql56 to mysql57as well:
sed -i.bak 's/mysql56/mysql57/g' /Applications/MAMP/Library/bin/mysqld_safe
Finally, if you use MAMP and set a my.cnf file, that should be set in /Applications/MAMP/conf/my.cnf… But by doing this upgrade, the default search path of the my.cnf in MAMP will be /usr/local/mysql/etc/ instead of the expected /Applications/MAMP/conf/ since that is where the new binary expects it to be set. Clearly we’re not going to recompile MySQL at this point so the cleanest/simplest thing to do to make your MAMP setup truly portable again is to change this line in the startMysql.sh from this:
/Applications/MAMP/Library/bin/mysqld_safe --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log &
To this; note we are adding the --defaults-extra-file= option before all the otgers:
/Applications/MAMP/Library/bin/mysqld_safe --defaults-extra-file=/Applications/MAMP/conf/my.cnf --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log &
With all of that command line work done, launch MAMP via the application, start the MySQL and Apache servers and then drop back into the command like to run this command to upgrade the databases:
/Applications/MAMP/Library/bin/mysql_upgrade --user=root --password=root --port=3306 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --force
And finally run this command to get the mysql.sock properly set for MAMP path instead of that /tmp/mysql.sock path:
/Applications/MAMP/Library/bin/mysql_config_editor --verbose set --socket=/Applications/MAMP/tmp/mysql/mysql.sock
When this is all done, and you have confirmed MySQL is running as expected, just toss the old MySQL 5.6 directory like this:
sudo rm -rf /Applications/MAMP/db/mysql56
With all that done you should all be set to cleanly use MySQL 5.7 under MAMP 4.4.1.
I encountered problems upgrading to MySQL 5.7.22 described in Giacomo1968’s answer.
The updated procedure worked well on El Capitan with MySQL 5.7.18.
I have written an updated bash script for this procedure:
#!/bin/sh
curl -OL https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-macos10.12-x86_64.tar.gz
tar xfvz mysql-5.7*
echo "Stopping MAMP"
sudo /Applications/MAMP/bin/stop.sh
sudo killall httpd mysqld
echo "Copy Bin"
sudo rsync -arv --progress mysql-5.7.*/bin/* /Applications/MAMP/Library/bin/ --exclude=mysqld_multi --exclude=mysqld_safe
echo "Copy Share"
sudo rsync -arv --progress mysql-5.7.*/share/* /Applications/MAMP/Library/share/
echo "Building Mysql 5.7 Folder"
sudo cp -r /Applications/MAMP/db/mysql56 /Applications/MAMP/db/mysql57
sudo rm -rf /Applications/MAMP/db/mysql57/mysql/innodb_*
sudo rm -rf /Applications/MAMP/db/mysql57/mysql/slave_*
sudo chown -R ${USER}:admin /Applications/MAMP/db/mysql57
sed -i.bak 's/mysql56/mysql57/g' /Applications/MAMP/Library/bin/mysqld_safe
echo "Finally, if you use MAMP and set a my.cnf file, that should be set in /Applications/MAMP/conf/my.cnf… But by doing this upgrade, the default search path of the my.cnf in MAMP will be /usr/local/mysql/etc/ instead of the expected /Applications/MAMP/conf/ since that is where the new binary expects it to be set. Clearly we’re not going to recompile MySQL at this point so the cleanest/simplest thing to do to make your MAMP setup truly portable again is to change this line in the startMysql.sh from this:
/Applications/MAMP/Library/bin/mysqld_safe --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log &
To this; note we are adding the --defaults-extra-file= option before all the otgers:
/Applications/MAMP/Library/bin/mysqld_safe --defaults-extra-file=/Applications/MAMP/conf/my.cnf --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log &"
read -p "With all of that command line work done, launch MAMP via the application, start the MySQL and Apache servers."
read -p "Press [Enter] key to start migration..."
echo "Starting MySQL"
/Applications/MAMP/Library/bin/mysql_upgrade --user=root --password=root --port=3306 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --force
echo "Migrate, finaly, to new version"
/Applications/MAMP/Library/bin/mysql_config_editor --verbose set --socket=/Applications/MAMP/tmp/mysql/mysql.sock
I am installing MySql Server in my Ubuntu. Steps are as the following:
Firt, I download the Linux Gerneric version of mysql: mysql-5.6.27-linux-glibc2.5-x86_64.tar.gz
I untar the downloaded package and copy all the contents to /usr/local/mysql: cp -r mysql-5.6.27-linux-glibc2.5-x86_64 /usr/local/mysql
I add group and user: 'groupadd mysql' and 'useradd -r -g mysql mysql'
Then I get into /usr/local/mysql folder, and use: 'chown -R mysql:mysql ./' to make mysql be the owner of the current folder.
Use './scripts/mysql_install_db --user=mysql' for installing MySql database. Then I added owner using 'chown -R root:root ./' and 'chown -R mysql:mysql data
I try to start MySql using 'support-files/mysql.server start', it tried to start the db but failed with error:
I could not find any .pid file in data folder:
but just a 'iZ23uaxhiftZ.err' file:
I have tried some solutions provided on the Internet, but get no luck, so how can I solve this? Thank!
I have run a binary install of MariaDB, i will provide the following commands that i used.
(Forgive me I have a fairly basic level of mysql so I have annotated with my understanding of what the commands do).
Added group called mysql
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
Untars the mariaDB binaries into which directory you choose.
shell> tar zxvf /usr/local/mysql/mysql-VERSION-OS.tar.gz
Created a symbolic link.
shell> ln -s /usr/local/mysql/mysql-VERSION-OS mysql
shell> cd mysql
Recursively changes ownership to the user/group.
shell> chown -R mysql .
shell> chgrp -R mysql .
Runs the mysql install db.
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
Makes a copy of the my.cnf file to put into the etc folder
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
Makes a copy of the server file to the init.d file which allows it to start automatically
shell> cp support-files/mysql.server /etc/init.d/mysql.server
Running my my_secure_installation script
./mysql_secure_installation --basedir=/usr/local/mysql/mariadb-5.5.34-linux-x86_64
I then closed the terminal and reopened, did:
ps -ef | grep mysql
to check the mysqld server was running (it was).
So I have done the above steps, I try and enter:
mysql -u root -p
and I receive the error
bash: mysql: command not found.
Any ideas why I cannot access it? Thanks in advance.