<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Commands on Michael’s Domain</title><link>https://jeltsch.org/en/tags/commands/</link><description>Recent content in Commands on Michael’s Domain</description><generator>Hugo</generator><language>en-us</language><copyright>Copyright © 2002 - 2026 Michael Jeltsch.</copyright><lastBuildDate>Fri, 24 Jul 2026 00:18:18 +0300</lastBuildDate><atom:link href="https://jeltsch.org/en/tags/commands/index.xml" rel="self" type="application/rss+xml"/><item><title>Adding a new user to MySQL and other basic mysql commands</title><link>https://jeltsch.org/en/adding_a_new_user_to_mysql_and_other_basic_mysql_commands/</link><pubDate>Mon, 18 Sep 2006 00:00:00 +0000</pubDate><guid>https://jeltsch.org/en/adding_a_new_user_to_mysql_and_other_basic_mysql_commands/</guid><description>&lt;p&gt;Crontab entry to backup all mysql databases to a file every midnight:&lt;code&gt;0 0 * * * mysqldump -u mjeltsch -h localhost --all-databases | gzip -9 &amp;gt; /home/mjeltsch/Documents/mysqldump.gz &amp;gt; /dev/null&lt;/code&gt;Granting privileges to users connecting from localhost:&lt;code&gt;GRANT ALL PRIVILEGES ON *.* TO 'michael'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;&lt;/code&gt;Granting privileges to users connecting from everywhere:&lt;code&gt;GRANT ALL PRIVILEGES ON *.* TO 'michael'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;&lt;/code&gt;Show all available databases:&lt;code&gt;SHOW DATABASES;&lt;/code&gt;Show all entries of the table &amp;ldquo;users&amp;rdquo;:SELECT * FROM users;Load database &amp;ldquo;phpgedview&amp;rdquo;:USE phpgedview;Create a new database named &amp;ldquo;phpgedview&amp;rdquo;:CREATE DATABASE phpgedview;Delete the database named &amp;ldquo;phpgedview&amp;rdquo;:DROP DATABASE phpgedview;Start mysql client as user michael and user database &amp;ldquo;phpgedview&amp;rdquo;:mysql &amp;ndash;user=michael -p phpgedviewDelete the user &amp;ldquo;test&amp;rdquo;:mysql&amp;gt; use mysql;mysql&amp;gt; delete from user where user=&amp;lsquo;test&amp;rsquo;;mysql&amp;gt; FLUSH PRIVILEGES;Changing the password for the user phpgedview being user root (this works also for changing the password for root):/usr/bin/mysql -u root -pSET PASSWORD FOR phpgedview@&amp;ldquo;localhost&amp;rdquo; = PASSWORD(&amp;lsquo;NewPassWord&amp;rsquo;);After installing the Suse rpm for mysql, execute the following commands:&lt;code&gt;sudo /usr/bin/mysql_install_db&lt;/code&gt;This creates the default databases &amp;amp; permissions. Apparently the same can be done by:&lt;code&gt;sudo rcmysql start&lt;/code&gt;Using SuSE you should use the Yast runlevel editor to start the mysql server automatically at boot time. To start the mysql server manually:&lt;code&gt;sudo /usr/bin/mysqld_safe --user=mysql &amp;amp;&lt;/code&gt;REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! This is done with:&lt;code&gt;/usr/bin/mysqladmin -u root password 'new-password'&lt;/code&gt;If you access the mysql server from another machine you need to specify the hostname:&lt;code&gt;/usr/bin/mysqladmin -u root -h hostname password 'new-password'&lt;/code&gt;Give all privileges to root and user:&lt;code&gt;mcblpc2:/home/user /usr/bin/mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 to server version: 4.0.15 Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql&amp;gt; GRANT ALL PRIVILEGES ON *.* TO user@localhost IDENTIFIED BY 'Password' WITH GRANT OPTION; Query OK, 0 rows affected (0.00 sec)mysql&amp;gt; GRANT ALL PRIVILEGES ON *.* TO user@'%' IDENTIFIED BY 'Password' WITH GRANT OPTION; Query OK, 0 rows affected (0.00 sec)mysql&amp;gt; GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'Password' WITH GRANT OPTION; Query OK, 0 rows affected (0.00 sec)mysql&amp;gt; GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'Password' WITH GRANT OPTION; Query OK, 0 rows affected (0.00 sec)mysql&amp;gt; quit Bye&lt;/code&gt;Check the mysql version:&lt;code&gt;/usr/bin/mysqladmin -u root -p version&amp;quot; is necessary&lt;/code&gt;Check the mysql variables:&lt;code&gt;/usr/bin/mysqladmin -u root -p variables&lt;/code&gt;Shut down the mysql server:&lt;code&gt;/usr/bin/mysqladmin -u root -p shutdown&lt;/code&gt;Check whether the server can be started:&lt;code&gt;sudo /usr/bin/mysqld_safe --log &amp;amp;&lt;/code&gt;Show all databases:&lt;code&gt;/usr/bin/mysqlshow -u root -p&lt;/code&gt;Show the tables of database &amp;ldquo;mysql&amp;rdquo;:&lt;code&gt;/usr/bin mysqlshow -u root -p mysql&lt;/code&gt;Show the columns of the table named &amp;rsquo;tablename&amp;rsquo;:&lt;code&gt;show columns from tablename;&lt;/code&gt;Remove whitespaces from the column named &amp;lsquo;columnname&amp;rsquo; in the table named &amp;rsquo;tablename&amp;rsquo;:&lt;code&gt;update &lt;/code&gt;tablename&lt;code&gt;set&lt;/code&gt;columnname&lt;code&gt;= trim(' ' from&lt;/code&gt;columnname&lt;code&gt;);&lt;/code&gt;Remove trailing line breaks from the column named &amp;lsquo;columnname&amp;rsquo; in the table named &amp;rsquo;tablename&amp;rsquo; (you might need to execute this repeatedly for some strange reason to remove all carriage returns and line feeds):&lt;code&gt;update &lt;/code&gt;tablename&lt;code&gt;set&lt;/code&gt;columnname&lt;code&gt;= trim(trailing '\n' from&lt;/code&gt;columnname&lt;code&gt;);update &lt;/code&gt;tablename&lt;code&gt;set&lt;/code&gt;columnname&lt;code&gt;= trim(trailing '\r' from&lt;/code&gt;columnname&lt;code&gt;);&lt;/code&gt;&lt;/p&gt;</description></item></channel></rss>