Guide to accessing cPanel MySQL database from your local machine

I'm currently facing an issue with connecting to the MySQL database from my Express server in cPanel. Both the database and server are located within cPanel. I've already created a user and attempted to connect using localhost, but unfortunately it's not working as expected. Here is the code snippet:

const db = mysql.createPool({
  host: "localhost",
  user: \\user\\,
  password: \\password\\,
  database: "ts34mpr_SCMP",
  dateStrings: true,
});

Despite ensuring that the user has all privileges and verifying that the username and password are correct, the request does not seem to be reaching the database. Any assistance would be greatly appreciated. Thank you!

Answer №1

To grant remote access to MySQL, you can simply use the wildcard character `%` (source: https://example.com/allow-remote-mysql-access). Alternatively, you can specify the specific IP address that is causing the error, leading to a message like this:

Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'username'@'123.45.***.***' (using password: YES)

Answer №2

Give this a shot:

const mysql = require('mysql');
const connection = mysql.createConnection({
    host: '127.0.0.1',
    user: 'admin',
    password: 'password123',
    database: 'cms'
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

javascript calculate average based on user input array

There is a problem that I am trying to solve, but as a beginner it seems quite challenging. Here is the code I have written so far, however, when I run it only one window appears. Any advice or guidance would be greatly appreciated. var years = prompt(" ...

Is there a way for me to display a customized error message using antd components?

During the registration process using React and Antd, if the backend returns the error message "user already registered" after clicking on "Sign up", it should be displayed in the form. You can customize the display as shown below: An example of how the u ...

Exploring the Process of Obtaining _Value Properties within Vue 3 Ref

Hello, I've been attempting to access the values from the _value property in Vue without success. How can I retrieve these values such as accessKey, align, ariaAtomic, etc.? Specifically, I am interested in getting the value of clientWidth. https://i ...

Internet Explorer encounters errors when processing LESS code

Currently experimenting with the combination of LESS and respond.js to facilitate the development of a new website. Both LESS and respond are incredibly useful tools. However, encountered several issues with LESS in Internet Explorer. Initially, while in ...

Exploring ThreeJS by Casting Rays on HTML Elements

We are currently encountering an issue with ThreeJS. Our goal is to integrate HTML elements into ThreeJS and use raycasting to determine whether we are pointing to any HTML element. However, when we intersect with it, it returns an empty array. An example ...

Encountering dependency resolution issues while attempting to install Material UI v5

Encountering a series of dependency resolution errors while attempting to install Material UI. The root cause remains unclear despite previous attempts to resolve issues by upgrading to V5 from V4 due to React compatibility reasons. However, additional con ...

Error thrown: Uncaught TypeError - Attempted to access 'params' property of undefined object in the context of StudentDetails

I've encountered an issue where I need to transfer student application data from my server-side to my client-side. Whenever a new student application is created, I want to display their information on my StudentDetails.jsx file. Here is my Server.js c ...

Having trouble connecting through PDO, but no issues when using the command line

UPDATE: I tried connecting to the command line using the following command mysql -u root -proot -h 127.0.0.1, but it didn't work. However, connecting without the -h option worked fine. This suggests there might be an issue with the MariaDB configurati ...

Utilizing the componentDidUpdate method to update the state within the component

I have a scenario where two components are enclosed in a container. One component is retrieving the Id of a publication, while the other is fetching the issue date related to that specific publicationId. When I retrieve an Id, let’s say 100, it successf ...

Simultaneous fading and displaying of the navbar

Currently, I'm in the process of constructing a navigation bar using Bootstrap v4 and have encountered an issue with the collapsing animation in responsive view. Upon inspection of the specific navigation bar, I noticed that the classes (.in and .s ...

Browse through content without displaying the page title on the navigation bar and without the use of frames

When I sign into certain websites, I have noticed that the address displayed is often something like this: https://examplesite.com/access Even though all the links on the landing page are clickable and functional, their corresponding addresses never show ...

Ways to store the output of a <script src> tag into a variable

How can I retrieve the output of a file in JavaScript? I am looking to achieve: var list = <script src="src/users.json"></script> Is it feasible to accomplish this using JavaScript? ...

What separates $(document).ready() from embedding a script at the end of the body tag?

Can you explain the distinction between running a JavaScript function during jQuery's $(document).ready() and embedding it in the HTML within script tags at the bottom of the body? Appreciate your insights, DLiKS ...

How to calculate time difference in minutes using Jquery

Currently, I am working on a web page featuring a list of records retrieved from a database. Each record has a corresponding timestamp, and my goal is to calculate the time difference in minutes between that timestamp and the current time using MySQL. Is ...

Exploring an object to retrieve values based on keys using javascript

Currently, I have an array of objects set up like this: https://i.sstatic.net/l6d3z.png My goal is to loop through the array and extract users based on a specific roomCode So, I've attempted two different approaches: for(let i=0; i <data. ...

Choosing the number of items for each cartItem in KnockoutJS: A comprehensive guide

Greetings! I am new to using knockout and I am attempting to automatically select the quantity for each item in my cart from a dropdown menu. Below is the code I have written: VIEW <div data-bind="foreach: cartItems"> <h3 data-bind="text: ful ...

What could be causing me difficulty in integrating NProgress into my Next.js application?

Despite following all the necessary steps for implementing the nprogress package, I am facing an issue where the loading bar shows up when routes are changed but nprogress fails to function properly. I have attempted alternative ways such as linking the st ...

Close overlay panel in PrimeFaces calendar

One of the components I’m currently working with is an overlayPanel that contains a calendar. Here's a snippet of the code: <p:overlayPanel hideEffect="fade" showCloseIcon="true" dismissable="true" > <h:form> <p:p ...

Trouble with parsing JSON in NodeJs

I have a JSON file containing the names of people that are stored. Using the Node Manager's filesystem, I read the content from this file and attempt to convert the JSON to a string and then parse it into a JavaScript object. However, after parsing it ...

Is it possible to reference the prior value of a computed Angular signal in any way?

Is it possible to dynamically add new values from signal A to the existing values in signal B, similar to how the scan operator works in RxJS? I am looking for something along the lines of signalB = computed((value) => [...value, signalA()]). Any sugg ...