Can't connect to local MySQL Server with homebrew - mysql

I have installed the MySQL-Server with homebrew before on another User on my Macbook Pro, but I must change the User and now I can't start the MySQL server:
$ mysql.server start
Starting MySQL
./usr/local/Cellar/mysql/5.7.22/bin/mysqld_safe: line 144:
/usr/local/var/mysql/Stefans-MacBook-Pro.local.err: Permission denied
/usr/local/Cellar/mysql/5.7.22/bin/mysqld_safe: line 144:
/usr/local/var/mysql/Stefans-MacBook-Pro.local.err: Permission denied
/usr/local/Cellar/mysql/5.7.22/bin/mysqld_safe: line 198:
/usr/local/var/mysql/Stefans-MacBook-Pro.local.err: Permission denied
/usr/local/Cellar/mysql/5.7.22/bin/mysqld_safe: line 144:
/usr/local/var/mysql/Stefans-MacBook-Pro.local.err: Permission denied
ERROR! The server quit without updating PID file
(/usr/local/var/mysql/Stefans-MacBook-Pro.local.pid).
The User "Stefan" doesn't exist anymore. Maybe the rights on /usr/local/var/mysql are not correct, but I am unsure about what I can do to fix it.
The rights are:
$ sudo ls -lah /usr/local/var/mysql/
Password:
total 221392
drwxr-xr-x 20 501 admin 640B 25 Apr 15:47 .
drwxrwxr-x 8 501 admin 256B 20 Apr 10:12 ..
-rw-r----- 1 501 admin 60K 25 Apr 15:47 Stefans-MacBook-Pro.local.err
-rw-r----- 1 501 admin 56B 20 Apr 10:12 auto.cnf
-rw------- 1 501 admin 1,6K 20 Apr 10:12 ca-key.pem
-rw-r--r-- 1 501 admin 1,1K 20 Apr 10:12 ca.pem
-rw-r--r-- 1 501 admin 1,1K 20 Apr 10:12 client-cert.pem
-rw------- 1 501 admin 1,6K 20 Apr 10:12 client-key.pem
-rw-r----- 1 501 admin 464B 25 Apr 15:47 ib_buffer_pool
-rw-r----- 1 501 admin 48M 25 Apr 15:47 ib_logfile0
-rw-r----- 1 501 admin 48M 20 Apr 10:12 ib_logfile1
-rw-r----- 1 501 admin 12M 25 Apr 15:47 ibdata1
drwxr-x--- 77 501 admin 2,4K 20 Apr 10:12 mysql
drwxr-x--- 90 501 admin 2,8K 20 Apr 10:12 performance_schema
-rw------- 1 501 admin 1,6K 20 Apr 10:12 private_key.pem
-rw-r--r-- 1 501 admin 452B 20 Apr 10:12 public_key.pem
-rw-r--r-- 1 501 admin 1,1K 20 Apr 10:12 server-cert.pem
-rw------- 1 501 admin 1,6K 20 Apr 10:12 server-key.pem
drwxr-x--- 108 501 admin 3,4K 20 Apr 10:12 sys
drwxr-x--- 25 501 admin 800B 20 Apr 12:00 textspinner
I have also tried to reinstall MySQL server but it doesn't work.
How can I fix this?

Ok, with this post i could fix this:
https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks

Related

Why i got many replay log files on mac where no replication is running?

Mysql on mac is generating a lot of relay log files, but no replication is actually running. So why? How to delete them?
mysql> SHOW SLAVE STATUS ;
Empty set, 1 warning (0.01 sec)
ls data/
...
-rw-r----- 1 _mysql _mysql 156 27 Jan 09:36 my-mac-relay-bin.000117
-rw-r----- 1 _mysql _mysql 156 27 Jan 11:41 my-mac-relay-bin.000118
-rw-r----- 1 _mysql _mysql 179 27 Jan 23:04 my-mac-relay-bin.000119
-rw-r----- 1 _mysql _mysql 156 28 Jan 09:25 my-mac-relay-bin.000120
-rw-r----- 1 _mysql _mysql 156 28 Jan 12:36 my-mac-relay-bin.000121
-rw-r----- 1 _mysql _mysql 156 29 Jan 18:57 my-mac-relay-bin.000122
-rw-r----- 1 _mysql _mysql 179 29 Jan 22:34 my-mac-relay-bin.000123
-rw-r----- 1 _mysql _mysql 179 30 Jan 22:28 my-mac-relay-bin.000124
...

Ubuntu 17.10 - ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I've seen similar questions being asked on stack overflow but none of them seem to solve my issue properly. I have recently upgraded my system from Ubuntu 16.04 to Ubuntu 17.10 . Since then, I've been experiencing a problem with mysql where I'm not able to start it up properly and it shows the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)
I've searched for many solutions online and as a last effort also tried uninstalling and reinstalling but the problem resurfaces after a few days or few attempts. Upon running "service mysql start", it shows:
Job for mysql.service failed because the control process exited with
error code.
See "systemctl status mysql.service" and "journalctl -xe" for
details.
Upon running the suggested commands it shows the following logs:
systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor
preset: enabled)
Active: activating (start-post) (Result: exit-code) since Thu 2018-
02-22 09:06:31 IST; 4s ago
Process: 8936 ExecStart=/usr/sbin/mysqld (code=exited,
status=1/FAILURE)
Process: 8930 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre
(code=exited, status=0/SUCCESS)
Main PID: 8936 (code=exited, status=1/FAILURE); Control PID: 8937
(mysql-systemd-s)
Tasks: 2 (limit: 4915)
CGroup: /system.slice/mysql.service
└─control
├─8937 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─8948 sleep 1
Feb 22 09:06:31 vamshi-Lenovo-G50-70 systemd[1]: Starting MySQL
Community Server...
Feb 22 09:06:32 vamshi-Lenovo-G50-70 mysqld[8936]: 2018-02-
22T03:36:31.948822Z 0 [Warning] Changed limits: max_open_files: 1024
(requested 5000)
Feb 22 09:06:32 vamshi-Lenovo-G50-70 mysqld[8936]: 2018-02-
22T03:36:31.948879Z 0 [Warning] Changed limits: table_open_cache: 431
(requested 2000)
Feb 22 09:06:32 vamshi-Lenovo-G50-70 mysqld[8936]: 2018-02-
22T03:36:32.126417Z 0 [Warning] TIMESTAMP with implicit DEFAULT value
is deprecated. Please use --explicit_def
Feb 22 09:06:32 vamshi-Lenovo-G50-70 mysqld[8936]: 2018-02-
22T03:36:32.128149Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.21-
0ubuntu0.17.10.1) starting as process 8936 ...
Feb 22 09:06:32 vamshi-Lenovo-G50-70 mysqld[8936]: 2018-02-
22T03:36:32.130652Z 0 [ERROR] Could not open file
'/var/log/mysql/error.log' for error logging: No such file o
Feb 22 09:06:32 vamshi-Lenovo-G50-70 mysqld[8936]: 2018-02-
22T03:36:32.130675Z 0 [ERROR] Aborting
Feb 22 09:06:32 vamshi-Lenovo-G50-70 mysqld[8936]: 2018-02-
22T03:36:32.130694Z 0 [Note] Binlog end
Feb 22 09:06:32 vamshi-Lenovo-G50-70 mysqld[8936]: 2018-02-
22T03:36:32.130750Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
Feb 22 09:06:32 vamshi-Lenovo-G50-70 systemd[1]: mysql.service: Main
process exited, code=exited, status=1/FAILURE
journalctl -xe
Feb 22 09:11:21 vamshi-Lenovo-G50-70 gnome-shell[2902]:
[AppIndicatorSupport-WARN] Attempting to re-register
:1.69/org/ayatana/NotificationItem/multiload; resetting inst
Feb 22 09:11:21 vamshi-Lenovo-G50-70 gnome-shell[2902]:
[AppIndicatorSupport-WARN] Item
:1.69/org/ayatana/NotificationItem/multiload is already registered
ESCOD
Every time this happens, I uninstall mysql and reinstall(server not client), and then it works alright for the first few attempts, then it goes back to same situation. Thanks in advance!
ls -al
total 32824
drwxrwxr-x 8 root syslog 4096 Feb 22 08:44 .
drwxr-xr-x 14 root root 4096 Feb 16 2017 ..
-rw-r--r-- 1 root root 1527 Feb 17 08:58 alternatives.log
-rw-r----- 1 root adm 0 Feb 22 08:44 apport.log
-rw-r----- 1 root adm 486 Feb 21 07:29 apport.log.1
-rw-r----- 1 root adm 455 Feb 20 20:54 apport.log.2.gz
-rw-r----- 1 root adm 514 Feb 19 21:42 apport.log.3.gz
-rw-r----- 1 root adm 758 Feb 19 18:15 apport.log.4.gz
-rw-r----- 1 root adm 459 Feb 17 23:07 apport.log.5.gz
-rw-r----- 1 root adm 1389 Feb 16 00:33 apport.log.6.gz
-rw-r----- 1 root adm 275 Feb 14 20:16 apport.log.7.gz
drwxr-xr-x 2 root root 4096 Feb 17 08:55 apt
-rw-r----- 1 syslog adm 86558 Feb 22 09:17 auth.log
-rw-r----- 1 syslog adm 97522 Feb 18 18:02 auth.log.1
-rw------- 1 root utmp 0 Feb 14 20:17 btmp
drwxr-x--- 2 root lp 4096 Feb 22 08:44 cups
drwxr-xr-x 2 root root 4096 Feb 5 14:51 dist-upgrade
-rw-r--r-- 1 root root 30036 Feb 17 08:58 dpkg.log
drwx--x--x 2 root gdm 4096 Feb 14 20:18 gdm3
-rw-r--r-- 1 root root 2136 Feb 22 08:39 gpu-manager.log
-rw-r----- 1 syslog adm 3745433 Feb 22 09:28 kern.log
-rw-r----- 1 syslog adm 2302923 Feb 18 18:07 kern.log.1
-rw-rw-r-- 1 root utmp 0 Feb 14 20:17 lastlog
-rw-r----- 1 syslog adm 657 Feb 22 08:40 mail.log
-rw-r----- 1 syslog adm 1971 Feb 18 15:31 mail.log.1
-rw-r----- 1 syslog adm 3706136 Feb 22 09:28 syslog
-rw-r----- 1 syslog adm 18760212 Feb 22 08:44 syslog.1
-rw-r----- 1 syslog adm 989385 Feb 21 07:07 syslog.2.gz
-rw-r----- 1 syslog adm 587416 Feb 20 09:09 syslog.3.gz
-rw-r----- 1 syslog adm 593456 Feb 19 18:21 syslog.4.gz
-rw-r----- 1 syslog adm 672682 Feb 18 18:07 syslog.5.gz
-rw-r----- 1 syslog adm 166575 Feb 17 09:09 syslog.6.gz
-rw-r----- 1 syslog adm 891827 Feb 16 00:44 syslog.7.gz
-rw-r----- 1 syslog adm 572158 Feb 22 09:28 ufw.log
-rw-r----- 1 syslog adm 234885 Feb 18 18:06 ufw.log.1
drwxr-xr-x 2 root root 4096 Feb 15 22:00 unattended-upgrades
drwxr-xr-x 2 root root 4096 Feb 22 08:40 vmware
-rw-rw-r-- 1 root utmp 20736 Feb 22 08:41 wtmp
Create folder /var/log/mysql and make sure mysqld can write to it.

Recover mysql using data folder

One of our MySQL servers died but somehow we were able to recover all the files from it. This server was a slave at one time however we stopped it being a slave so we could use it for housekeeping tasks and reports, etc.
Can someone tell me how to recover with this?
I now have these files and a backup of my.cnf
ll /root/home/recovered/mysql/
-rw-r----- 1 root root 117 Jun 1 09:30 rabney-relay-bin.000001
-rw-r----- 1 root root 26 Jun 1 09:30 rabney-relay-bin.index
-rw-r----- 1 root root 113055367168 Jun 1 10:42 ibdata1
-rw-r----- 1 root root 1073741824 Jun 1 09:33 ib_logfile0
-rw-r----- 1 root root 1073741824 Jun 1 09:33 ib_logfile1
drwx------ 2 root root 4096 Jun 1 09:30 mysql
drwx------ 2 root root 16384 Jun 1 09:30 production_copy
-rw-r----- 1 root root 3253518648 Jun 1 09:32 slowquery.log
drwx------ 2 root root 4096 Jun 1 09:30 test
I've been reading articles on Google regarding this but not sure how to do it yet.

Does GT.M save database operation command in logs file

I see that have some logs file create by gt.m but just only about mupip rundown or recover information
> root#localhost:/tmp/fis-gtm/V6.2-002_x86_64# ll total 68 drwxrwxrwt 2
> root root 4096 Jul 14 16:22 ./ drwxr-xr-x 3 root root 4096 Jul 13
> 14:32 ../
> -rw-r--r-- 1 root root 0 Jul 13 14:33 root_20150713073215UTC-20150713073319UTC_mupip_rundown
> -rw-r--r-- 1 root root 278 Jul 13 14:32 root_20150713073215UTC_mupip_recover
> -rw-r--r-- 1 root root 0 Jul 14 11:11 root_20150713073407UTC-20150714041129UTC_mupip_rundown
> -rw-r--r-- 1 root root 278 Jul 13 14:34 root_20150713073407UTC_mupip_recover
> -rw-r--r-- 1 root root 278 Jul 14 09:46 root_20150714024647UTC_mupip_recover
> -rw-r--r-- 1 root root 0 Jul 14 09:49 root_20150714024820UTC-20150714024941UTC_mupip_rundown
> -rw-r--r-- 1 root root 278 Jul 14 09:48 root_20150714024820UTC_mupip_recover
> -rw-r--r-- 1 root root 77 Jul 14 09:55 root_20150714025001UTC-20150714025500UTC_mupip_rundown
> -rw-r--r-- 1 root root 291 Jul 14 09:50 root_20150714025001UTC_mupip_recover
> -rw-r--r-- 1 root root 0 Jul 14 10:03 root_20150714030230UTC-20150714030331UTC_mupip_rundown
> -rw-r--r-- 1 root root 311 Jul 14 10:02 root_20150714030230UTC_mupip_recover
> -rw-r--r-- 1 root root 0 Jul 14 14:35 root_20150714030424UTC-20150714073509UTC_mupip_rundown
> -rw-r--r-- 1 root root 260 Jul 14 10:04 root_20150714030424UTC_mupip_recover
Where do I find logs about GTM command like : SET ^,WRIRE....?
Normal commands (Set, Write) are part of the core programming language and are not logged; they are journalled if they read or write something to disk. The question is what are you looking for?

Rogue Database Appears in MySQL Show Databases

I see today that
show databases
displays an unknown database:
(msl_ampcs_v4_0_0_2g)> show databases;
+----------------------+
| Database |
+----------------------+
| information_schema |
| #mysql50#.ssh |
| global_lad
Normally when I see something like that it is due to a bad file in /var/lib/mysql:
-rw-r--r-- 1 mysql mysql 1663 Mar 17 2011 /var/lib/mysql/ca-cert.pem
drwx------ 2 mysql mysql 4096 Jun 18 15:00 /var/lib/mysql/global_lad
drwx------ 2 mysql mysql 4096 Jun 18 15:00 /var/lib/mysql/global_lad_unit_test
-rw-rw---- 1 mysql mysql 3231711232 Aug 22 07:20 /var/lib/mysql/ibdata1
-rw-rw---- 1 mysql mysql 5242880 Aug 22 07:20 /var/lib/mysql/ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 Aug 21 16:25 /var/lib/mysql/ib_logfile1
-rw-rw---- 1 mysql mysql 5 Feb 21 2013 /var/lib/mysql/istsdb2.jpl.nasa.gov.pid
-rw-rw---- 1 mysql mysql 4596466 Oct 15 2010 /var/lib/mysql/istsdb2-slow.log
drwx------ 2 mysql mysql 4096 Jul 13 2011 /var/lib/mysql/msl_ampcs_v2_0_0
drwx------ 2 mysql mysql 4096 Jul 21 2012 /var/lib/mysql/msl_ampcs_v3_0_0
drwx------ 2 mysql mysql 4096 Jun 20 02:55 /var/lib/mysql/msl_ampcs_v4_0_0
drwx------ 2 mysql mysql 4096 Sep 5 19:45 /var/lib/mysql/msl_ampcs_v4_0_0_2g
drwx------ 2 mysql mysql 4096 Sep 30 2010 /var/lib/mysql/msl_gdsdb_v5_0
drwx------ 2 mysql mysql 4096 Jan 19 2011 /var/lib/mysql/msl_gdsdb_v5_5
drwx------ 2 mysql mysql 4096 Nov 21 2011 /var/lib/mysql/msl_gdsdb_v5_6
drwx------ 2 mysql root 4096 Mar 23 2010 /var/lib/mysql/mysql
srwxrwxrwx 1 mysql mysql 0 Feb 21 2013 /var/lib/mysql/mysql.sock
-rw------- 1 root root 841 Jun 10 2010 /var/lib/mysql/nohup.out
drwx------ 2 mysql mysql 4096 Feb 5 2013 /var/lib/mysql/pdpp_automation
-rw-r--r-- 1 mysql mysql 1310 Mar 17 2011 /var/lib/mysql/server-cert.pem
-rw-r--r-- 1 mysql mysql 1679 Mar 17 2011 /var/lib/mysql/server-key.pem
But nothing like that is present. The nohup shouldn't be there. But
#mysql50#.ssh
does not appear.