≡ Menu

mysqladmin command

Check The Number Of MySQL Open Database Connections on Linux Or Unix-like Server

I'm a new MySQL server user. My server is running on a CentOS Linux. How can I check the number of active MySQL connections on Linux based system?
[click to continue…]

Find Out MySQL Version

How do I find out mysql version under Linux or Unix operating systems?
[click to continue…]

HowTo: Find Out MySQL Server Version Number

How do I find out mysql server version number under UNIX / Linux operating systems?
[click to continue…]

RedHat / CentOS Install and Configure Cacti Network Graphing Tool

Cacti is a network graphing tool similar to MRTG. How do I install and configure common options to collect SNMP data and various other data (such as system load, network link status, hard disk space, logged in users etc) into an RRD?
[click to continue…]

OpenBSD Install MySQL Server

Q. How do I install and run MySQL version 5 database Server under OpenBSD UNIX operating system?

A. OpenBSD has pkg_add command. It is used to install packages created with the pkg_create command. Selected packages containing pre-compiled applications from the /usr/ports tree can be found on the OpenBSD FTP site or on the official OpenBSD CD. pkg_add is the easiest way to install new packages, to replace existing packages with other flavors (option -r) or to update packages to newer versions option -u).

Install MySQL Database Server on OpenBSD

First setup installation mirror i.e. PKG_PATH using export command:
$ export PKG_PATH=ftp://mirror.planetunix.net/pub/OpenBSD/4.1/packages/`machine -a`/
Next install MySQL server, using pkg_add command, enter:
$ sudo pkg_add -i -v mysql-server
# pkg_add -i -v mysql-server

parsing mysql-server-5.0.33
Dependencies for mysql-server-5.0.33 resolve to: p5-DBD-mysql-3.0008, mysql-client-5.0.33 (todo: mysql-client-5.0.33,p5-DBD-mysql-3.0008)
mysql-server-5.0.33:parsing mysql-client-5.0.33
mysql-server-5.0.33:mysql-client-5.0.33: complete
mysql-server-5.0.33:parsing p5-DBD-mysql-3.0008
Dependencies for p5-DBD-mysql-3.0008 resolve to: mysql-client-5.0.33, p5-DBI-1.53 (todo: p5-DBI-1.53)
mysql-server-5.0.33:parsing p5-DBI-1.53
Dependencies for p5-DBI-1.53 resolve to: p5-PlRPC-0.2018p0 (todo: p5-PlRPC-0.2018p0)
mysql-server-5.0.33:parsing p5-PlRPC-0.2018p0
Dependencies for p5-PlRPC-0.2018p0 resolve to: p5-Net-Daemon-0.39 (todo: p5-Net-Daemon-0.39)
mysql-server-5.0.33:parsing p5-Net-Daemon-0.39
mysql-server-5.0.33:p5-Net-Daemon-0.39: complete
mysql-server-5.0.33:p5-PlRPC-0.2018p0: complete
mysql-server-5.0.33:p5-DBI-1.53: complete
mysql-server-5.0.33:p5-DBD-mysql-3.0008: complete
adding group _mysql
adding user _mysql
installed /etc/my.cnf from /usr/local/share/mysql/my-medium.cnf****************************************************************************************************     | 97%
mysql-server-5.0.33: complete
--- mysql-server-5.0.33 -------------------
The mysql-server package doesn't initialize a default database.
Please run /usr/local/bin/mysql_install_db to create one.

Install default MySQL database

By default MySQL database is not initialized, enter the following command to create a default database:
# /usr/local/bin/mysql_install_db

Installing all prepared tables
Fill help tables
To do so, start the server, then issue the following commands:
/usr/local/bin/mysqladmin -u root password 'new-password'
/usr/local/bin/mysqladmin -u root -h openbsd.nixcraft.in password 'new-password'
See the manual for more instructions.

Start MySQL server

Now you have MySQL server installed. Start the server daemon, enter:
# /usr/local/bin/mysqld_safe &

[1] 7750
Starting mysqld daemon with databases from /var/mysql

Connect to MySQL server

Run mysql command to test if everything is working fine, enter:
# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.33-log OpenBSD port: mysql-server-5.0.33
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> quit

Set root password

You must set a password for the MySQL root user, enter:
# /usr/local/bin/mysqladmin -u root password 'YOUR-Secret-Password'
To access the MySQL server with password, enter:
$ mysql -u root -p

Create MySQL startup and stop script

Finally, you need a script to start and stop MySQL Server. In order to start MySQL server at boot time, enter following command in /etc/rc.conf.local file:
# vi /etc/rc.conf.local
Append following line:
Save and close the file. Now you need to edit /etc/rc.local file. It is use to specify site-specific startup actions, daemons, and other things which can be done AFTER your system goes into securemode:
# vi /etc/rc.local
Find out line which read as follows:
# Add your local startup actions here.
Append following code:

# MySQL startup
if [ X"${mysql}" == X"YES" -a -x /usr/local/bin/mysqld_safe ]; then
   echo -n " mysqld "
   /usr/local/bin/mysqld_safe --user=_mysql &

Save and close the file.

How do I stop MySQL server under OpenBSD?

Use mysqladmin command:
# mysqladmin -u root -p shutdown

Change MySQL root password

Q. How do I change MySQL server root password under Linux / UNIX operating system at shell prompt?

A. You need to mysqladmin command which is a client for performing administrative operations. You can use it to check the server’s configuration and current status, to create and drop databases, change mysql root password and more.

How do I change mysql root password?

If you are setting a root password first time, use any one of the following command syntax:
mysqladmin password "NEW-PASSWORD"
mysqladmin -u root password "NEW-PASSWORD"
mysqladmin -u root -h localhost password "NEW-PASSWORD"

To set password to d3s9cXq, enter:
# mysqladmin -u root password "d3s9cXq"

Please note that if the NEW-PASSWORD value contains spaces or other characters that are special to your command interpreter, you need to enclose it within quotes. Thus, the next time you invoke mysqladmin (or any other client program such as mysql) using the same account, you will need to specify the new password. So to login as root, enter the command:
# mysql -u root -p
# mysql -h localhost -u root -p


  • -u root: Specify username
  • -p : Prompt for password

If you would like to change current password d3s9cXq to OlzzYs$qz, enter the following command:
# mysqladmin -u root -p password "OlzzYs$qz"

Enter password: <enter old password>

MySQL Change root Password

How do I change MySQL root password under Linux, FreeBSD, OpenBSD and UNIX-like like operating system over the ssh session?
[click to continue…]

Mysql User Creation: Setting Up a New MySQL User Account

How do I create a user account on MySQL database server?
[click to continue…]