<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Database Management &#8211; TECH POINT MAGAZINE</title>
	<atom:link href="https://techpointmag.com/tag/database-management/feed/" rel="self" type="application/rss+xml" />
	<link>https://techpointmag.com</link>
	<description>-Beyond Technology-</description>
	<lastBuildDate>Wed, 12 Apr 2023 19:27:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.5</generator>

<image>
	<url>https://techpointmag.com/wp-content/uploads/2019/06/cropped-tech-point-logo@2x-3-32x32.png</url>
	<title>Database Management &#8211; TECH POINT MAGAZINE</title>
	<link>https://techpointmag.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">141627558</site>	<item>
		<title>How to Create a new user in MySQL</title>
		<link>https://techpointmag.com/how-to-create-a-new-user-in-mysql/</link>
		
		<dc:creator><![CDATA[Humphrey Mpairwe]]></dc:creator>
		<pubDate>Wed, 12 Apr 2023 19:27:03 +0000</pubDate>
				<category><![CDATA[Guides]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Database Management]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL Database]]></category>
		<guid isPermaLink="false">https://techpointmag.com/?p=16460</guid>

					<description><![CDATA[MySQL is a popular open-source database management system&#160;(DBMS)&#160;used in millions of applications across the world. Unlike other database systems, you can create a new user in MySQL without sophisticated tools or commands in your access diameter. To successfully create your user, all you need is access to the MySQL console or a GUI tool such [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>MySQL is a popular open-source database management system&nbsp;(DBMS)&nbsp;used in millions of applications across the world. Unlike other database systems, you can create a new user in MySQL without sophisticated tools or commands in your access diameter. To successfully create your user, all you need is access to the MySQL console or a GUI tool such as PHPMyAdmin.</p>



<p>As a norm, each time you create a new user in MySQL, you must assign the user correct privileges to access and manage databases on your MySQL cluster. Failure to assign the user correct privileges may lead to little or no access to all MySQL databases.</p>



<p>In this article, we’ll create a new user in MySQL identified with the name `example-user` you will have to replace with your desired username. It’s also important to note that you must have administrative access to the MySQL Shell, then, follow the steps in this article to create your new database user account.</p>



<figure class="wp-block-image size-full"><a href="https://techpointmag.com/wp-content/uploads/2023/04/MySQL.jpg"><img fetchpriority="high" decoding="async" width="750" height="500" src="https://techpointmag.com/wp-content/uploads/2023/04/MySQL.jpg" alt="Create a new user in MySQL" class="wp-image-16606" srcset="https://techpointmag.com/wp-content/uploads/2023/04/MySQL.jpg 750w, https://techpointmag.com/wp-content/uploads/2023/04/MySQL-300x200.jpg 300w, https://techpointmag.com/wp-content/uploads/2023/04/MySQL-696x464.jpg 696w" sizes="(max-width: 750px) 100vw, 750px" /></a></figure>



<h2 class="wp-block-heading">Step 1: Log in to&nbsp;the&nbsp;MySQL&nbsp;Console</h2>



<p>To log in to the MySQL console, make sure you have a user account with administrative privileges. If you are running <a href="https://techpointmag.com/how-to-delete-files-on-linux-using-the-rm-command/" data-type="post" data-id="16238">Linux</a>, you can simply use the <code>sudo</code> command to attain root privileges and log in without a password as below.</p>



<pre class="wp-block-code"><code>$ sudo mysql</code></pre>



<p>If you have an administrative username and password, run the following command:</p>



<pre class="wp-block-code"><code>$ mysql -u username-here -p</code></pre>



<h2 class="wp-block-heading">Step 2: Create&nbsp;a new MySQL&nbsp;User</h2>



<p>Once logged in to the MySQL console, create the user <code>example-user</code> by running the following command:</p>



<pre class="wp-block-code"><code>CREATE USER 'example-user'@'localhost' IDENTIFIED BY 'strong-passsword';</code></pre>



<p>In the above command, <code>example-user</code> is the new MySQL user account. <code>localhost</code> defines that you are running MySQL client on the same database server.<code>strong-password</code> represents the user password which must be strong enough to protect your MySQL server.</p>



<h2 class="wp-block-heading">Step 3: Grant the MYSQL User Privileges to Databases</h2>



<p>Now that the user is created, you must grant the MySQL user necessary privileges to one or more databases. These privileges determine what the user can do on the database whether create, read, update, or delete data which you can set as below.</p>



<pre class="wp-block-preformatted">GRANT &lt;PRIVILEGE> ON &lt;Database> TO &lt;user> @ &lt;database-server></pre>



<p>The privileges determine what the user can do in MySQL. For example, you can grant the user the privileges to create, read, update, and delete data, or you can limit the user to only read from the database.</p>



<p>Grant the MySQL user full privileges to all databases.</p>



<pre class="wp-block-code"><code>GRANT ALL PRIVILEGES ON .* TO 'example-user'@'localhost';</code></pre>



<p>Grant the MySQL user full privileges to a single database. For example, the <code>example</code> database.</p>



<pre class="wp-block-code"><code>GRANT ALL PRIVILEGES ON example.* TO 'example-user'@'localhost';</code></pre>



<p>Once applied, the MySQL user only has privileges to the selected databases, and not any other on the server. This is important when grouping users in form of departments to limit what they can access.</p>



<h2 class="wp-block-heading">Step 4: Flush Privileges&nbsp;to Save MySQL user permissions</h2>



<p>Once you create a new user in MySQL or change permissions, you must refresh the database privileges for changes to take effect. To flush privileges, simply run the following command:</p>



<pre class="wp-block-code"><code>FLUSH PRIVILEGES</code></pre>



<p>Upon flushing privileges, the MySQL privilege tables are refreshed with new data. This ensures that your changes to the database server users and permissions are applied.</p>



<h2 class="wp-block-heading">Test the new MySQL User</h2>



<p>To verify that the new MySQL user is well created and the assigned password works well, exit the MySQL console. Then, log in again using the new MySQL user as described below.</p>



<p>First, exit the MYSQL console.</p>



<pre class="wp-block-code"><code>EXIT</code></pre>



<p>Log in as the new user.</p>



<pre class="wp-block-code"><code>$ mysql -u example-user -p</code></pre>



<p>Enter the user password when prompted.</p>



<p>Verify that the user has access to the assigned databases.</p>



<pre class="wp-block-code"><code>SHOW DATABASES;</code></pre>



<p>Exit the MySQL console.</p>



<pre class="wp-block-code"><code>EXIT</code></pre>



<h2 class="wp-block-heading">Do More each time you Create a New User in MySQL</h2>



<p>In this article, you have successfully set up a new user in MySQL and assigned the necessary privileges to allow the user access available databases. The above process is important when setting up new applications such as websites that require database access to keep the rest of your databases safe. For more information about MySQL, please visit its <a href="https://dev.mysql.com/doc/" target="_blank" rel="noopener"><u>official documentation</u></a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">16460</post-id>	</item>
	</channel>
</rss>
