Mysql without root privilege - mysql

How do I start mysql without having root privileges/write access to tool area ?
I am getting following error
host13:~/JS> mysqld start
160706 18:06:31 [Warning] Can't create test file /tool/p64/.package/mysql-5.5.21/data/host13.lower-test
160706 18:06:31 [Warning] Can't create test file /tool/p64/.package/mysql-5.5.21/data/host13.lower-test
mysqld: Table 'mysql.plugin' doesn't exist
160706 18:06:31 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
160706 18:06:31 InnoDB: The InnoDB memory heap is disabled
160706 18:06:31 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160706 18:06:31 InnoDB: Compressed tables use zlib 1.2.3
160706 18:06:31 InnoDB: Initializing buffer pool, size = 128.0M
160706 18:06:31 InnoDB: Completed initialization of buffer pool
160706 18:06:31 InnoDB: Operating system error number 30 in a file operation.
InnoDB: Error number 30 means 'Read-only file system'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/operating-system-error-codes.html
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.

You can move MySQL data directory to where you are able to write, and then specify it in /etc/my.cnf (or possibly another location depending on your system defaults), the parameter is datadir.
If your data directory has not yet been initialized (in which case mysqld will complain about missing privilege tables) you can create them like this:
mysql_install_db --datadir=$path_to_new_datadir

Summarizing the answer:
# Setup DB
mysql_install_db --datadir=<FULL PATH TO STORE DB FILES>
# Start server
mysqld --datadir=<FULL PATH TO STORE DB FILES>
# Shutdown server
mysqladmin -u root shutdown
Notes:
1. The = after datadir - without which commands will fail
2. Full path should be used

Related

Moving MySQL data to another drive

I want to move my data in C:\ProgramData\MySQL\MySQL Server 5.5\data to E:\Mysql5Data
Stopped MySQL5 Service
Changed "datadir" value in my.ini file to E:/Mysql5Data
Started MySQL5 Service
I got 1067 Process terminated unexpectedly error while starting MySQL.
Update:
Logs
160509 13:18:56 [Warning] Can't create test file C:\Program Files\MySQL\MySQL Server 5.5\data\DGNLWEBBIP01.lower-test
160509 13:18:56 [Warning] Can't create test file C:\Program Files\MySQL\MySQL Server 5.5\data\DGNLWEBBIP01.lower-test
160509 13:18:56 [Note] Plugin 'FEDERATED' is disabled.
160509 13:18:56 InnoDB: The InnoDB memory heap is disabled
160509 13:18:56 InnoDB: Mutexes and rw_locks use Windows interlocked functions
160509 13:18:56 InnoDB: Compressed tables use zlib 1.2.3
160509 13:18:56 InnoDB: Initializing buffer pool, size = 128.0M
160509 13:18:56 InnoDB: Completed initialization of buffer pool
160509 13:18:56 InnoDB: Operating system error number 5 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory. It may also be you have created a subdirectory
InnoDB: of the same name as a data file.
InnoDB: File name .\ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
SOLUTION:
Murray's comment

Error Starting MySQL after Crash

I was merrily installing wordpress with MAMP pro when my Mac crashed. Now I cannot start MySql. Most stuff I read online tells me to throw some terminal commands at it, trying to kill the process.
killall -9 mysqld
But terminal report "No matching processes belonging to you were found"
So I have had a look in the log and can see this from the time of the first restart attempt after the crash
150506 21:11:33 mysqld_safe Starting mysqld daemon with databases from /Library/Application Support/appsolute/MAMP PRO/db/mysql
150506 21:11:33 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
150506 21:11:33 [Warning] Setting lower_case_table_names=2 because file system for /Library/Application Support/appsolute/MAMP PRO/db/mysql/ is case insensitive
150506 21:11:33 [Note] Plugin 'FEDERATED' is disabled.
150506 21:11:33 InnoDB: The InnoDB memory heap is disabled
150506 21:11:33 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150506 21:11:33 InnoDB: Compressed tables use zlib 1.2.3
150506 21:11:33 InnoDB: Initializing buffer pool, size = 128.0M
150506 21:11:33 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
150506 21:11:33 InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
150506 21:11:33 InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
150506 21:11:33 InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
150506 21:11:34 InnoDB: Waiting for the background threads to start
150506 21:11:35 InnoDB: 5.5.42 started; log sequence number 0
150506 21:11:35 [Note] Event Scheduler: Loaded 0 events
150506 21:11:35 [Note] /Applications/MAMP/Library/bin/mysqld: ready for connections.
Version: '5.5.42' socket: '/Applications/MAMP/tmp/mysql/mysql.sock' port: 0 Source distribution
150506 21:16:44 [Note] /Applications/MAMP/Library/bin/mysqld: Normal shutdown
So Table Space size error.. I am very much a front end guy and have no idea where to begin with this...??
Help please, I really can't afford to loose the last week of work.
Thanks you
As you pointed out InnoDB tablespace is corrupt, so InnoDB fails to start.
InnoDB can tolerate some errors if you start it with option innodb_force_recovery. Try values from 1 to 6 until MySQL starts.
If you're lucky and MySQL starts with innodb_force_recovery then dump all tables into an sql file with mysqldump and re-create MySQL database from scratch. I.e. move existing files to some safe place, start mysql_install_db, change file permissions and start MySQL. Then load the database back.
If you're less lucky and MySQL doesn't start with innodb_force_recovery=6 then check how to Recover Corrupt MySQL Database .
And to avoid this experience in future use XtraBackup for Mac OS to take backups.
Please see her:
MAMP PRO crashes; MySQL will not start on reboot
Thanks for the heads up with Xtrabackup for MacOS, one to keep an eye on that.

Can't initiate mysql in MAC OS X 10.7.5

I installed MySQL through a package located in MySQL site.
I changed this directory:
/usr/local/mysql-5.5.28-osx10.5-x86/data
For _mysql
However, when I try to do mysqld start, I get the following errors and warnings:
121018 18:04:17 [Warning] Can't create test file /usr/local/mysql-5.5.28-osx10.5-x86/data/homer.lower-test
121018 18:04:17 [Warning] Can't create test file /usr/local/mysql-5.5.28-osx10.5-x86/data/homer.lower-test
121018 18:04:17 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
121018 18:04:17 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
121018 18:04:17 InnoDB: The InnoDB memory heap is disabled
121018 18:04:17 InnoDB: Mutexes and rw_locks use InnoDB's own implementation
121018 18:04:17 InnoDB: Compressed tables use zlib 1.2.3
121018 18:04:17 InnoDB: Initializing buffer pool, size = 128.0M
121018 18:04:17 InnoDB: Completed initialization of buffer pool
121018 18:04:17 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
Any tips on what can be happening?
The easiest thing to do is to install the System Preferences plugin that you get with the download and start/stop MySQL using that. You can set it there to start automatically when the system restarts.

Mysql problem: no mysql.sock

Yesterday I was working using MySQL installed on my computer.
I downloaded xampp, so I have I changed on my.cnf file the path to the socket:
/opt/lampp/var/mysql/mysql.sock
That file was just there. Today I wanted to keep working on it, and I found that file is not there anymore, so I am getting the following error while I am starting mysql server:
ERROR 2002 (HY000):
Can't connect to local MySQL server through socket
'/opt/lampp/var/mysql/mysql.sock' (2)
Here are some tests I made:
mujeresponja#ubuntu:~$ ps -fea | grep mysqld
1000 15707 15615 0 16:28 pts/1 00:00:00 grep --color=auto mysqld
mujeresponja#ubuntu:~$ ps -fea | grep mysql
1000 15709 15615 0 16:29 pts/1 00:00:00 grep --color=auto mysql
As a possible solution I uninstalled xampp and reinstall it, and also a new MySQL server, just in case. Anyway, that file is not there anymore.
EDIT
Where the mysql.sock should be, instead there are two files mysql_upgrade_info (Which contains just 5.5.8) and another binary file called ubuntu.err:
mujeresponja#ubuntu:/opt/lampp/var/mysql$ sudo cat ubuntu.err
110403 17:28:52 mysqld_safe Starting mysqld daemon with databases from /opt/lampp/var/mysql
110403 17:28:52 [Note] Plugin 'FEDERATED' is disabled.
/opt/lampp/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
110403 17:28:52 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use InnoDB's own implementation
InnoDB: Compressed tables use zlib 1.2.3
110403 17:28:52 InnoDB: Initializing buffer pool, size = 16.0M
110403 17:28:52 InnoDB: Completed initialization of buffer pool
110403 17:28:52 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name /opt/lampp/var/mysql/ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
110403 17:28:52 mysqld_safe mysqld from pid file /opt/lampp/var/mysql/ubuntu.pid ended
110403 17:29:22 mysqld_safe Starting mysqld daemon with databases from /opt/lampp/var/mysql
110403 17:29:22 [Note] Plugin 'FEDERATED' is disabled.
/opt/lampp/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
110403 17:29:22 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use InnoDB's own implementation
InnoDB: Compressed tables use zlib 1.2.3
110403 17:29:22 InnoDB: Initializing buffer pool, size = 16.0M
110403 17:29:22 InnoDB: Completed initialization of buffer pool
110403 17:29:22 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name /opt/lampp/var/mysql/ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
110403 17:29:22 mysqld_safe mysqld from pid file /opt/lampp/var/mysql/ubuntu.pid ended
(Sorry, I don't know how to show terminal messages in an appropiuate way)
Can anybody help me on this? Thanks in advance!
You can locate the actual socket file and create a symbolic link leading to it as follows:
# check path to socket from mysql settings
mysqladmin | grep d.sock
# create a symbolic link
ln -s path_to_mysql_socket /opt/lampp/var/mysql/mysql.sock
Although the test you did is a bit garbled, Im going to assume that the test just prove mysql isnt running.
Depending on how the mysql configured itself there should be a startup file somewhere, usually around the /etc/rc.* directories, and you would need to run the rc.mysql start (or it could be a S<nn>MySQL in an rc3.d directory for example
I didn't find a certain reason for my problem.
I just unisntalled and reinstalled, and then everything went Ok.
That is not a real solution, but it worked. Good luck
I came in the same situation when I made a grant to *.* to other user. Mysql tried to give permissions over the mysql database and that provoked the disaster: instantly, the mysql.sock file disappeared.
this happened with the version 5.6
I had the same problem with you, and I found some useful information:
2015-08-14 10:51:17 30934 [ERROR] InnoDB: Unable to lock /opt/lampp/var/mysql/ibdata1, error: 11
2015-08-14 10:51:17 30934 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
So, I rebooted the computer and restarted XAMPP, and the problem was resolved.

MySQL 5.5.9 Wont Start

I installed mysql version 5.5.9 on my mac and I tried to start it using this command :
sudo /usr/local/mysql/support-files/mysql.server start
mysql didn't start with this command. I checked the localhost.err file in data directory and it was like this :
110227 22:51:14 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
110227 22:51:14 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
110227 22:51:14 [Note] Plugin 'FEDERATED' is disabled.
/usr/local/mysql/bin/mysqld: Table 'mysql.plugin' doesn't exist
110227 22:51:14 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110227 22:51:14 InnoDB: The InnoDB memory heap is disabled
110227 22:51:14 InnoDB: Mutexes and rw_locks use GCC atomic builtins
110227 22:51:14 InnoDB: Compressed tables use zlib 1.2.3
110227 22:51:14 InnoDB: Initializing buffer pool, size = 128.0M
110227 22:51:14 InnoDB: Completed initialization of buffer pool
110227 22:51:14 InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
110227 22:51:14 InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
110227 22:51:15 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
110227 22:51:15 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
110227 22:51:15 InnoDB: Waiting for the background threads to start
110227 22:51:16 InnoDB: 1.1.5 started; log sequence number 1595916
110227 22:51:16 [ERROR] /usr/local/mysql/bin/mysqld: unknown option '--skip-locking'
110227 22:51:16 [ERROR] Aborting
110227 22:51:16 InnoDB: Starting shutdown...
110227 22:51:16 InnoDB: Shutdown completed; log sequence number 1595916
110227 22:51:16 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
110227 22:51:16 mysqld_safe mysqld from pid file /usr/local/mysql/data/localhost.pid ended
I deleted the two ib_log files, I changed my.cnf file and I got nothing.
--skip-locking was removed in MySQL 5.5. See here.
Edit your my.cnf file and change "skip-locking" to "skip-external-locking".
I had this same issue on mac, I have other MySQL instances installed from MAMP and XAMP.
Do a locate in terminal: locate my.cnf
Take note of any other my.cnf files not located in your AMPPS directory.
I found that when i removed /private/etc/my.cnf, MySQL started with no issues.
sudo mv /private/etc/my.cnf /private/etc/my-old.cnf
1 ) in the terminal , launch command : mysql_upgrade ( to create the tables that are non existent )
2 ) edit /etc/my.cnf , comment out the --skip-locking statement
that's all , happy SQLing