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.
Related
In my local terminal, after running:
mysql -u root -p
it returns:
bash: /usr/local/mysql: No such file or directory
Yes, I have installed everything as:
(envir) MBPganghinanban:ADB_nov20_2021 xxx$ brew services stop mysql
Stopping `mysql`... (might take a while)
==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql)
(envir) MBPganghinanban:ADB_nov20_2021 xxx$ mysql.server start
Starting MySQL
. SUCCESS!
(envir) MBPganghinanban:ADB_nov20_2021 xxx$ mysql.server stop
Shutting down MySQL
. SUCCESS!
The part I suspect is that I have executed this previously:
alias mysql=/usr/local/mysql
In addition, it also returns "No such file or directory" if I run:
mysql
I am not sure of not being able to execute "mysql -u root -p" while being able to login to the server. Please help.
Thanks to the community. I have followed the instruction from Cid, meanwhile I have used:
which mysql
Hence, I found the path of my installation is at: /usr/local/bin/mysql
Then
export PATH="/usr/local/bin/mysql”
The problem is solved!
My XAMPP mysql server is working fine
then I download the separate mysql from oracle and installed it. It is running fine but after some days I cant start it as :> mysql -u root
and in xampp mysql server it is also not working it shows stopped always.
I am providing all the commands that I tried from google as well as StackOverflow
and also I am providing all results of all commands.
Please refer commands before answering.
Number indicates ways that I tried.
1.> `mysql -u root -p`
2.> `mysql -u root`
3.> `sudo su`
3.1.> `ps aux | grep mysql`
3.2.> `kill -9 8306`
4.> `sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start`
5.> `sudo killall mysqld`
6.> Changing content of file as: `innodb_force_recovery = 1` in
`/Applications/XAMPP/xamppfiles/etc/my.cnf`
7.> Changing content of file as: read only permission in
`/Applications/XAMPP/xamppfiles/etc/my.cnf`
8.> Port changed from 3306 to 3307 3308 but nothing is happened
9.> Activity manager : mysql service is. not listed
10.> Reinstalled XAMPP
I followed this 10 ways so please dont answer on this 10 ways
Result of commands :
<.1.
Pratiks-MacBook-Pro:~ pratik$ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock' (2 "No such file or directory")
<.2.
Pratiks-MacBook-Pro:~ pratik$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock' (2 "No such file or directory")
<.3.
Pratiks-MacBook-Pro:~ pratik$ sudo su
Password:
sh-3.2# ps aux | grep mysql
root 8306 0.0 0.0 4258468 180 s000 U+ 11:35AM 0:00.00 grep mysql
sh-3.2# kill -9 8306
sh: kill: (8306) - No such process
sh-3.2#
<.4.
Pratiks-MacBook-Pro:~ pratik$ sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
Starting MySQL
.2018-03-13 11:44:29 8513 mysqld_safe Logging to '/Applications/XAMPP/xamppfiles/var/mysql/Pratiks-MacBook-Pro.local.err'.
2018-03-13 11:44:29 8513 mysqld_safe Starting mysqld daemon with databases from /Applications/XAMPP/xamppfiles/var/mysql
ERROR!
<.5.
Pratiks-MacBook-Pro:~ pratik$ sudo killall mysqld
No matching processes were found
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 need to check if mysql is installed on a ubuntu server. Is there a way to determine if mySql has been installed ? Thanks.
You can use tool dpkg for managing packages in Debian operating system.
Example
dpkg --get-selections | grep mysql if it's listed as installed, you got it. Else you need to get it.
"mysql" may be found even if mysql and mariadb is uninstalled, but not "mysqld".
Faster than rpm -qa | grep mysqld is:
which mysqld
Multiple ways of searching for the program.
Type mysql in your terminal, see the result.
Search the /usr/bin, /bin directories for the binary.
Type apt-cache show mysql to see if it is installed
locate mysql
With this command:
dpkg -s mysql-server | grep Status
# mysqladmin -u root -p status
Output:
Enter password:
Uptime: 4 Threads: 1 Questions: 62 Slow queries: 0 Opens: 51 Flush tables: 1 Open tables: 45 Queries per second avg: 15.500
It means MySQL serer is running
If server is not running then it will dump error as follows
# mysqladmin -u root -p status
Output :
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
So Under Debian Linux you can type following command
# /etc/init.d/mysql status
In an RPM-based Linux, you can check presence of MySQL like this:
rpm -qa | grep mysql
For debian or other dpkg-based systems, check like this:
*
dpkg -l mysql-server libmysqlclientdev*
*
Lots of answers. It should have been a simple command. Just type mysql --version on your terminal and hit enter.
Try executing 'mysql' or 'mysql -- version' without quotes on terminal.
it will prompt version otherwise Command Not Found
I have removed the preinstalled MySQL from CentOS 6 using the command-
yum remove mysql mysql-*
Now, I want to install "MySQl-server-5.5.28-1.linux2.6.i386.rpm" in my system.
But it could not start on my system. Please tell me how to start the MySQL with user account as well as in root also.
I have done this:-
[rex#dhcppc0 MySQL]$
[rex#dhcppc0 MySQL]$ su -
Password:
[root#dhcppc0 ~]# cd /home/rex/Documents/Software/MySQL
[root#dhcppc0 MySQL]# rpm -i MySQL-server-5.5.28-1.linux2.6.i386.rpm
package MySQL-server-5.5.28-1.linux2.6.i386 is already installed
[root#dhcppc0 MySQL]# mysql -u
-bash: mysql: command not found
[root#dhcppc0 MySQL]# mysql -u mysql
-bash: mysql: command not found
[root#dhcppc0 MySQL]# mysql.server start
-bash: mysql.server: command not found
MySQL-server-xxxx is package that contains only MySQL Server. Executable file for server is "mysqld" - "d" letter is for a daemon).
File that you trying to execute (mysql) is MySQL client. There is no client application in server package.
Please install MySQL-client-xxxx package, where xxxx is a version.
Execute the initscript below as a root user:
# /etc/init.d/mysql start
If you try to access the database from local client, you need to install MySQL-client-5.5.28-1.linux2.6.i686.rpm package.
Then you can control the MySQL database.
$ /usr/bin/mysql -u mysql