Mysql install and remove issues - mysql

I installed mysql on ubuntu server and i dont know what went wrong...it didnt install a mysql root user so i tried to uninstall and start over and now i cant unistall
i tried this
apt-get remove php5-mysql
apt-get remove mysql-server mysql-client
apt-get autoremove
but when i do
ps aux | grep mysql
root 6066 0.0 0.0 1772 540 pts/1 S 03:21 0:00 /bin/sh /usr/bin/mysqld_safe
mysql 7065 0.0 0.6 58936 11900 pts/1 Sl 03:33 0:00 /usr/sbin/mysqld -- basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid -- socket=/var/run/mysqld/mysqld.sock --port=3306
root 7066 0.0 0.0 2956 688 pts/1 S 03:33 0:00 logger -t mysqld -p daemon.error
root 22804 0.0 0.0 3056 780 pts/1 R+ 04:14 0:00 grep mysql
so i killed the processes and then tried to reinstall like this
apt-get -f install
sudo apt-get install mysql-server mysql-client
sudo mysqladmin -u root -h localhost password 'root'
but i get this
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
im confused..i keep installing and uninstalling mysql and the same result..any ideas

it's possible that mysql is using old config files from your previous installation.
the best way to remove a package is:
sudo dpkg --purge package name
This removes all obsolete config files as well!

The root password is stored in a special "mysql" database. Look in /var/lib/mysql/mysql and see if there is anything there.
In my case, I see:
# ls /var/lib/mysql/mysql
columns_priv.frm help_category.frm ndb_binlog_index.frm slow_log.CSM time_zone_transition.frm
columns_priv.MYD help_category.MYD ndb_binlog_index.MYD slow_log.CSV time_zone_transition.MYD
columns_priv.MYI help_category.MYI ndb_binlog_index.MYI slow_log.frm time_zone_transition.MYI
db.frm help_keyword.frm plugin.frm tables_priv.frm time_zone_transition_type.frm
db.MYD help_keyword.MYD plugin.MYD tables_priv.MYD time_zone_transition_type.MYD
db.MYI help_keyword.MYI plugin.MYI tables_priv.MYI time_zone_transition_type.MYI
event.frm help_relation.frm proc.frm time_zone.frm user.frm
event.MYD help_relation.MYD proc.MYD time_zone_leap_second.frm user_info.frm
event.MYI help_relation.MYI proc.MYI time_zone_leap_second.MYD user_info.MYD
func.frm help_topic.frm procs_priv.frm time_zone_leap_second.MYI user_info.MYI
func.MYD help_topic.MYD procs_priv.MYD time_zone.MYD user.MYD
func.MYI help_topic.MYI procs_priv.MYI time_zone.MYI user.MYI
general_log.CSM host.frm servers.frm time_zone_name.frm
general_log.CSV host.MYD servers.MYD time_zone_name.MYD
general_log.frm host.MYI servers.MYI time_zone_name.MYI
If so, delete that directory and then reinstall.
You can also start mysql in a special no-password mode and then reset the password.

Related

Cannot Start MYSQL Server Mac

I am currently trying to run mysql server on a mac, but the Start MySQL Server from the preferences pane doesn't work, and neither does starting it from the Terminal. I have found a lot of fixes, but none of them work. This is my first time using MySQL, I have very little (just a bit of Java) programming experience, and this is my first StackOverflow post in a long time (please help me learn if I did it incorrectly!).
I installed this version(didn't use brew): mysql-5.7.21-1-macos10.13-x86_64
My machine is 64 bit
What I've tried:
Uninstalled and reinstalled MySQL using this process:
To uninstall MySQL and completely remove it (including all databases) from your Mac do the following:
Open a terminal window Use mysqldump to backup your databases to text
files! Stop the database server sudo rm /usr/local/mysql sudo rm -rf
/usr/local/mysql* sudo rm -rf /Library/StartupItems/MySQLCOM sudo rm
-rf /Library/PreferencePanes/My* edit /etc/hostconfig and remove the line MYSQLCOM=-YES- rm -rf ~/Library/PreferencePanes/My* sudo rm -rf
/Library/Receipts/mysql* sudo rm -rf /Library/Receipts/MySQL* sudo rm
-rf /private/var/db/receipts/mysql https://community.jaspersoft.com/wiki/uninstall-mysql-mac-os-x
When I open the folder where mysql is installed, I do not have permissions to open the data or keychain folders. So, I decided it was a permissions problem and tried this: Cannot start Mysql on Mac. When I tried to start the server, I got the following error:
sudo /usr/local/mysql/support-files/mysql.server start Starting MySQL
.Logging to '/usr/local/mysql/data/XXXXs-MacBook-Air.local.err'.
/usr/local/mysql/bin/mysqld_safe: line 198: 7892 Trace/BPT trap: 5
nohup /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql
--datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=XXXXs-MacBook-Air.local.err --pid-file=/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid < /dev/null > /dev/null 2>&1 ERROR! The server quit without updating
PID file (/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid).
Tried to check the admin version and got the following error:
XXXXs-MacBook-Air:mysql XXXX$ bin/mysqladmin version mysqladmin:
connect to server at 'localhost' failed error: 'Can't connect to local
MySQL server through socket '/tmp/mysql.sock' (2)' Check that mysqld
is running and that the socket: '/tmp/mysql.sock' exists!
Tried to open /temp/mysql.sock from the command line and got that it does not exist
Tried this:
XXXXs-MacBook-Air:mysql XXXX$ % mysqladmin variables
-bash: fg: %: no such job XXXXs-MacBook-Air:mysql XXXX$ mysqladmin variables
-bash: mysqladmin: command not found
Tried removing my.cnf per this post and restarted the server
sudo rm -rf /etc/my.cnf
sudo /usr/local/mysql/support-files/mysql.server start
Tried these instructions MySql server startup error 'The server quit without updating PID file '
XXXXs-MacBook-Air:mysql XXXX$ ps -ef | grep mysql 501 9173
549 0 11:54PM ttys000 0:00.01 grep mysql
XXXXs-MacBook-Air:mysql XXXX$ kill -9 PID
-bash: kill: PID: arguments must be process or job IDs XXXXs-MacBook-Air:mysql XXXX$ ls -laF /usr/local/var/mysql/ ls:
/usr/local/var/mysql/: No such file or directory
XXXXs-MacBook-Air:mysql XXXX$ ls -laF /usr/local/mysql lrwxr-xr-x
1 root wheel 30 Apr 4 22:44 /usr/local/mysql# ->
mysql-5.7.21-macos10.13-x86_64 XXXXs-MacBook-Air:mysql XXXX$ sudo
chown -R mysql /usr/local/var/mysql/ Password: chown:
/usr/local/var/mysql/: No such file or directory
XXXXs-MacBook-Air:mysql XXXX$ sudo chown -R mysql /usr/local/mysql
XXXXes-MacBook-Air:mysql XXXX$ sudo
/usr/local/mysql/support-files/mysql.server start Starting MySQL
.Logging to '/usr/local/mysql/data/XXXXs-MacBook-Air.local.err'.
/usr/local/mysql/bin/mysqld_safe: line 198: 9327 Trace/BPT trap: 5
nohup /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql
--datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=XXXXs-MacBook-Air.local.err --pid-file=/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid < /dev/null > /dev/null 2>&1 . ERROR! The server quit without updating
PID file (/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid).
XXXXs-MacBook-Air:mysql XXXX$ unset TMPDIR
XXXXs-MacBook-Air:mysql XXXX$ mysql_install_db --verbose
--user=whoami --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
-bash: mysql_install_db: command not found
And now I'm back to this error:
ERROR! The server quit without updating PID file
(/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid).
Please help!
EDITED: I uninstalled and reinstalled with brew. Using these instructions: http://stefan.magnuson.co/articles/osx/reinstalling-mysql-on-osx-with-homebrew/ Now it works.
I uninstalled and reinstalled SQL with Homebrew using these instructions: http://stefan.magnuson.co/articles/osx/reinstalling-mysql-on-osx-with-homebrew/ Now it works.
This small diagnosis worked for me in MAC...
open Your Terminal and use the following command to check all the instances or mysql that are currently running in your machine.
1) ps -ef | grep mysql
If you found any process Id with the above command.
2) sudo kill -9 [PID]
Where [PID] is the process id next to username
now try restarting mysql again using the mysql server pane or go to terminal and type the following command
sudo /usr/local/mysql/support-files/mysql.server start

How to kill mysql started with "mysql_safe" script?

Short version: I started mysql with mysql_safe and I can't kill it.
Long version: Installing an older version of mysql with macport displayed this suggestion:
$ sudo port install mysql55-server
---> Computing dependencies for mysql55-server
---> Fetching archive for mysql55-server
---> Attempting to fetch mysql55-server-5.5.49_0.darwin_14.noarch.tbz2 from https://packages.macports.org/mysql55-server
---> Attempting to fetch mysql55-server-5.5.49_0.darwin_14.noarch.tbz2.rmd160 from https://packages.macports.org/mysql55-server
---> Installing mysql55-server #5.5.49_0
---> Activating mysql55-server #5.5.49_0
If this is a new install you might want to run:
$ sudo -u _mysql /opt/local/lib/mysql55/bin/mysql_install_db
Running that gave these instructions:
$ sudo -u _mysql /opt/local/lib/mysql55/bin/mysql_install_db
Installing MySQL system tables...
161102 13:15:44 [Note] /opt/local/lib/mysql55/bin/mysqld (mysqld 5.5.49) starting as process 54176 ...
OK
Filling help tables...
161102 13:15:44 [Note] /opt/local/lib/mysql55/bin/mysqld (mysqld 5.5.49) starting as process 54180 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/local/lib/mysql55/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql55/bin/mysqladmin -u root -h myusername password 'new-password'
Alternatively you can run:
/opt/local/lib/mysql55/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt/local ; /opt/local/lib/mysql55/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/local/mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
At this point I (unwisely, it seems) ran:
$ cd /opt/local ; /opt/local/lib/mysql55/bin/mysqld_safe &
Now I cannot figure out how to stop the mysql and/or daemondo process(es):
$ ps aux | grep mysql55
myusername 54937 0.1 0.0 2432772 660 s001 R+ 1:39PM 0:00.00 grep mysql55
_mysql 54888 0.0 0.1 2667884 6340 ?? S 1:36PM 0:00.12 /opt/local/lib/mysql55/bin/mysqld --user=_mysql
root 54885 0.0 0.0 2479468 700 ?? Ss 1:36PM 0:00.00 /opt/local/bin/daemondo --label=mysql55-server --start-cmd /opt/local/lib/mysql55/bin/mysqld --user=_mysql ; --pid=exec
I've tried many variations of kill, targeting both mysql (which seems pointless) and daemondo, including (but not limited to) the following:
sudo kill -9 54888 // killing the mysql process results in a new pid
sudo kill 54885 // the doemondo process
sudo kill -SIGHUP 54885
sudo killall mysqld_safe
sudo kill -9 54822 // a reincarnation of the doemondo process
sudo mysqladmin shutdown
For centos or mint
/usr/bin# initctl
for ubuntu
pkill mysqld

How to stop mysql on OsX from the command line

This question bas many answers, I tried what I found – did not work
So, I tried sudo mysqld stop.
Still I see the mysql processes running:
0 317 1 0 11:15AM ?? 0:00.02 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.pid
74 3562 317 0 11:40AM ?? 0:00.41 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.err --pid-file=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.pid
The same happens if I do “sudo kill -9 3562”.
Trying to go to /Library/LaunchDaemons does not retrieve any mysql entries
ls /Library/LaunchDaemons | grep mysql
The service command does not work:
-bash: service: command not found
My Os X version is 10.9.2
There are two answers I know, it might not help since you search a long time.
1.if you install mysql from dmg, you can close it in "system preferences".
2.And besides that, you can start/stop/restart mysql by:
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server restart
To install Homebrew, open Terminal/iTerm and run following command or check https://brew.sh/
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install mysql
$ brew install mysql.
Install brew services first
$ brew tap homebrew/services.
Start mysql
$ brew services start mysql.
In order to avoid mysqld from auto restarting after killed, try execute all these 3 commands:
$ brew services stop mysql
$ sudo launchctl unload /Library/LaunchDaemons/com.mysql.mysql.plist
$ sudo launchctl unload /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

mysql command line with xampp in ubuntu 14.04

I installed xampp. After I type sudo /opt/lampp/lampp start into terminal, I get
$ sudo /opt/lampp/lampp start
Starting XAMPP for Linux 5.6.23-0...
XAMPP: Starting Apache...ok.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.
I changed the root password in /opt/lampp/phpmyadmin/config.inc.php
The password in localhost/phpmyadmin agrees with the change made in the config.inc.php file.
When I type mysql -u root -p into terminal I get
The program 'mysql' can be found in the following packages:
* mysql-client-core-5.5
* mariadb-client-core-5.5
* mysql-client-core-5.6
* percona-xtradb-cluster-client-5.5
Try: sudo apt-get install <selected package>
I installed mysql-client-core-5.6
$ sudo apt-get install mysql-client-core-5.6
[sudo] password for experiment:
Reading package lists... Done
After installing the client, when I typed mysql -u root -p into terminal I got
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Some threads suggest that multiple instances of mysql could be running.
When I type ps ax | grep mysql into terminal, I get
$ ps ax | grep mysql
7021 ? S 0:00 /bin/sh /opt/lampp/bin/mysqld_safe --datadir=/opt/lampp/var/mysql --pid-file=/opt/lampp/var/mysql/experiment-MP061.pid
7168 ? Sl 0:02 /opt/lampp/sbin/mysqld --basedir=/opt/lampp --datadir=/opt/lampp/var/mysql --plugin-dir=/opt/lampp/lib/mysql/plugin/ --user=mysql --log-error=/opt/lampp/var/mysql/experiment-MP061.err --pid-file=/opt/lampp/var/mysql/experiment-MP061.pid --socket=/opt/lampp/var/mysql/mysql.sock --port=3306
11112 pts/6 S+ 0:00 grep --color=auto mysql
I don't know how to interpret the output. Is this one instance of mysql?
Some threads suggest making changes to the my.cnf file. I don't have one. I do have a etc/mysql/my.cnf.bak file. Where should I put the my.cnf file?
Should I be able to use the mysql command line after installing xampp only or do I need to install a client?
My ultimate goal is to have a system where I can use xampp, Workbench, NetBeans, and the mysql command line.
To find the path where my.cnf or my.ini is picked up, issue a command
mysql --help
It will echo out a lot of info. Search thru the text to find a line like the following:
Default options are read from the following files in the given order:
C:\WINDOWS\my.ini C:\WINDOWS\my.cnf C:\my.ini C:\my.cnf C:\Program Files\MySQL\MySQL Server 5.7\my.ini C:\Program Files\MySQL\MySQL Server 5.7\my.cnf
or
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
It is buried right in the middle of the echo output.
Lastly,
$ sudo netstat -tlpn | grep mysql
tcp6 0 0 :::3306 :::* LISTEN 10954/mysqld
port 3306.
If you have a few daemons running, you will get multiple lines. You use the -P (uppercase) switch at the cmd line for the port number. Note that lowercase -p is for the password (either prompt for it or give it)

MySQL deactivated in Lampp, Xampp on Linux 12.04

I have freshly installed xampp-linux-1.8.1 on my Ubuntu 12.04 (Mint 13 maya) Operating system.
When run lampp, I get :
/opt/lampp/lampp start
Starting XAMPP for Linux 1.8.1...
XAMPP: XAMPP-Apache is already running.
XAMPP: Another MySQL daemon is already running.
XAMPP: XAMPP-ProFTPD is already running.
XAMPP for Linux started.
In the : localhost/xampp/
MySQL DataBase is Deactivated !!!
ps -aux | grep 'mysql'
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html mysql 3159 0.0 0.9 316264 31880 ? Ssl 16:48 0:00 /usr/sbin/mysqld
root 4745 0.0 0.0 4648 840 pts/5 S+ 17:02 0:00 grep --color=auto mysql
When I tried to stop /usr/sbin/mysqld but it can't be stopped with this command !!!
/usr/sbin/mysqld stop
Please I need Help, Thanks.
i've resolved the issue in this way:
sudo chmod -R 777 /opt/lampp
sudo chown -hR nobody /opt/lampp
sudo chmod -R 755 /opt/lampp
then stop other mysqld running with:
sudo service mysql stop
Also had this issue, after troubleshooting for almost 2 hours I found that it was because of other Apache and MySQL packages also running on my system. Removed all Apache and MySQL packages and reinstalled XAMPP again. Success.