The path to my bin folder with mysql:
usr/local/mysql/bin
Here is my zshrc bash config:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin:/Users/leon/bin/subl"
export PATH="/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH"
When I type mysql I get the following
Commands run:
echo $PATH
/Users/leongaban/.nvm/versions/node/v5.8.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
which mysql
mysql not found
mysql --help
zsh: command not found: mysql
sudo find / -name mysql
Password:
/Applications/MySQLWorkbench.app/Contents/MacOS/mysql
ps -ef | grep mysql
74 96 1 0 11:18AM ?? 0:02.90 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/mysqld.local.err --pid-file=/usr/local/mysql/data/mysqld.local.pid --port=3307
501 16302 9174 0 1:27PM ttys001 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn mysql
Here are a few commands that might help determine more about the problem:
echo $PATH
which mysql
mysql --help
find / -name mysql
ps -ef | grep mysql
If you still have no clue you might post the output to those commands here. Also to paraphrase Alex Trebek, please phrase your post in the form of a question. What are you expecting to see?
My PATH was correct, however it was getting overridden by a PATH var lower in my .zshrc file
# User configuration
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
# export MANPATH="/usr/local/man:$MANPATH"
After commenting out that line, mysql works again.
Related
I have mysql installed on centos 7 on office, I expected it would have configuiration file located at /etc/mysql/my.cnf but I spotted directly under /etc.
is it possible to find out using the mysql cli the configuration file in use ?
Please refer here for details. The article discusses the default configuration file scan order.
But you could also specify the --defaults-file when starting mysql, please use ps -ef |grep mysql or similar command to check. On my machine, the output like this(suse12):
ps -ef |grep mysql
mysql 968 1 0 Apr27 ? 00:46:36 ./mysqld --defaults-file=/export/home/mysql/mysql-8.0.11/my.cnf --user=mysql
root 71136 65599 0 11:45 pts/0 00:00:00 grep --color=auto mysql
I removed mysql completely including configuration files and when I try to reinstall, there is no mysql.socket (I searched in /var/lib/mysql/ and there's nothing.
Typically you will see mysql.sock file when you start the mysql daemon process. This is create the sock file.
But you can also search and see whether it has created somewhere.
netstat -ln | grep -o -m 1 -E '\S*mysqld?\.sock'
or
you can check with this command:
% mysqladmin variables
If you want to create the file, you can do this
mkdir /var/mysql
ln -s /tmp/mysql.sock /var/mysql/mysql.sock
This thread explains things in more details.
First off, I know not to run as root normally. I have an abnormal situation: I need to use mysqldump with the --tab argument, which requires permission to write to disk, and I want to use those files outside the Docker container. I could explain why running mysqld as root makes this easier, but isn't this question long enough? Running as root is safe in this case because the container will be used only for running tests and for updating DB backup scripts based on SQL migration scripts, and it will be started to do 1 job and then taken back down again.
When I google for how to run mysqld as root, I find the answer indirectly given in instructions on how to NOT run as root. Among other things in order to run mysqld as user_name:
Start the server as user user_name. Another alternative is to start mysqld as the Unix root user and use the --user=user_name option.
To start the server as the given user automatically at system startup time, specify the user name by adding a user option to the [mysqld] group of the /etc/my.cnf option file or the my.cnf option file in the server's data directory.
Do we do one of those? Both of those? I'll assume both just in case. But do they really mean /etc/my.cnf, or does that depend on the installation (e.g. what Linux distribution)? E.g. Docker image mysql:5.6 has /etc/mysql/my.cnf. The directions for the MySql Docker image advise mounting a volume at /etc/mysql/conf.d which is referenced in the aforementioned my.cnf. (Doing so overwrites 2 configuration files that are there by default, so I used a COPY command in my Dockerfile instead to merely add a config file.) The file does make it into the container:
root#4f612d10a690:/etc/mysql/conf.d# cat my.cnf
[mysqld]
user=root
One further requirement from the MySql manual is to add the --user=root argument to mysqld. The official MySql image calls mysqld via its CMD, so I override that in my Dockerfile. My CMD command does indeed run (it is run in 2 places in official MySql image's entrypoint script):
# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
mysql 1 0.1 2.8 1452788 472756 ? Ssl 14:24 0:01 mysqld --user=root
Note that mysqld has the --user=root command I provided, but is running as the mysql user, not as root.
Here's my full Dockerfile:
FROM mysql:5.6
VOLUME ["/var/lib/mysql-files"]
COPY ["my.cnf", "/etc/mysql/conf.d"]
CMD ["mysqld", "--user=root"]
My only guess as to why it's not running as root is that they mysql image's entrypoint script changes to the mysql user before running:
# allow the container to be started with `--user`
if [ ...blah... -a "$(id -u)" = '0' ]; then
...blah...
exec gosu mysql "$BASH_SOURCE" "$#"
fi
The above snippet basically says, if the user is root, then run the supplied arguments (the CMD + args in this case) as the mysql user.
Is running mysqld as root simply not supported by the official MySql Docker image?
Note: this is how to run mysqld process as SO's root user, and not how to get the root MySQL user.
I don't know whether exists a better approach but this works.
Viewing the official entrypoint.sh, it seems that it has no support of chaging the default mysql user
I realized how to run mysql as root but you need to have already initialized the data directory.
Step 1) Start a normal mysql in order to initialize a volume (the mysql entrypoint.sh will do that job):
docker run \
--rm \
-v $(pwd)/mysql/:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD="abc" \
mysql:5.6
Step 2) Stop and remove that container:
docker stop <container-id>
Step 3) Start again a new mysql process based on the data dir that has been created, but this time avoid to run the official mysql entrypoint:
docker run \
-v $(pwd)/mysql/:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD="abc" \
--entrypoint mysqld \
mysql:5.6 \
--user root
Step 4) Check it:
▶ docker exec -it 4add4d065c3e bash
root#4add4d065c3e:/# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 2.8 23.0 1314864 471104 ? Ssl 15:12 0:00 mysqld --user root
root 28 3.0 0.1 20248 3040 ? Ss 15:12 0:00 bash
root 34 0.0 0.1 17500 2068 ? R+ 15:12 0:00 ps aux
I have installed zend server on my iMac. I can log on to zend server and i can log in to phpmyadmin, using user: root pw: (blank)
However. I am desperately trying to open mysql using the terminal. I have tried for 3h now and wiht all kinds of pathways and sudo-whatnot..
This i get when:
Williams-iMac:mysql uglyface$ cd /usr/local/zend/mysql/bin
Williams-iMac:bin uglyface$ ls
innochecksum mysql_config mysqlaccess.conf mysqlhotcopy
msql2mysql mysql_convert_table_format mysqladmin mysqlimport
my_print_defaults mysql_find_rows mysqladmin.client mysqlmanager
myisam_ftdump mysql_fix_extensions mysqlbinlog mysqlshow
myisamchk mysql_fix_privilege_tables mysqlbug mysqlslap
myisamlog mysql_secure_installation mysqlcheck mysqltest
myisampack mysql_setpermission mysqld mysqltest_embedded
mysql mysql_tzinfo_to_sql mysqld-debug perror
mysql.client mysql_upgrade mysqld_multi replace
mysql.server mysql_waitpid mysqld_safe resolve_stack_dump
mysql_client_test mysql_zap mysqldump resolveip
mysql_client_test_embedded mysqlaccess mysqldumpslow setup_mysql.sh
So in here i can se mysql, but i haven been able to do anything with it. I am sorry for way of displaying the output i get. I tried to get it to display differently but with no success as you can see...
Do any one know what i can do, so that i can log in to my mysql?
/W
edit: There is no mysql located in /usr/local/bin...
If mysql is running (you start it with the zend server controller), you should be able to do:
/usr/local/zend/mysql/bin/mysql -uroot -p <your dbname>
You can verify mysqld is running by a simple
ps -ef | grep mysqld
If it's running, you'll see more than just your grep command in the resulting process list.
Is there a way I can figure out which my.cnf mysql is currently using? The reason is because it's using the correct socket file to connect, but I can't figure out exactly which (if any) my.cnf it's using or trying to use so I can manually set the correct path on my local machine.
$ strace -f -e trace=open mysql 2>&1 | grep $SEARCH_STRING
where usually SEARCH_STRING='cnf' or SEARCH_STRING='ini'
The default extentions for the mysql configuration file are '.cnf' and '.ini' (see http://dev.mysql.com/doc/refman/5.1/en/option-files.html)
A bit hackish:
$ strace mysql 2>&1 | grep 'open' | grep '.cnf'
open("/etc/mysql/my.cnf", O_RDONLY|O_LARGEFILE) = 3
open("/home/reto/.my.cnf", O_RDONLY|O_LARGEFILE) = 3